I want data from datatable and replace comma with space [closed] - mysql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have query for to get data following :
select a from REPLACE(M,',','')TABLE;
I want to get all the data from table along with M column content replce , with space.

You select from the table. What you select belongs in the SELECT clause:
SELECT t.*, REPLACE(m, ',', '') FROM mytable t;

Related

how to check whether a column in mysql table is comma separated list of values of not [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a column media_type with sample following values
*media_type*
-------------------
socialmedia, paper
tv
paper, tv
pamplet,board
tv,board,pamplet
I would want to filter my promotions which are being advertised through only one media.
You can use locate():
select *
from mytable
where not locate(',', media_type)
This phrases as: get all rows whose media_type is not null and does not contain a comma.
A more portable approach uses like:
select *
from mytable
where media_type not like '%,%'

MySQL - Featch Records with limit in one table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have one table with 3 fields e.g.
Name, Team Name, Player_Number
there is multiple team and I want to fetch 2 member from each team.
Please share with fast solution.
Try this
select * from TableName s where (select count(*) from TableName a where a.TeamName = s.TeamName and a.Player_Number >= s.Player_Number) <= 2

how to convert colums to rows in sql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a table with the following values
and I need the output values as below.
Please help to arrive the code
It's not pretty, but this would work:
select *
from
(
select nams_contract_number, 1 as Sequence, 'Preqc' as DataType, act_preqc, est_preqc
from table
union all
select nams_contract_number, 2 as Sequence, 'abstractoin' as DataType, act_abstraction, est_abstraction
from table
union all
select nams_contract_number, 3 as Sequence, 'review' as DataType, act_review, est_review
from table
union all
select nams_contract_number, 4 as Sequence, 'postreview' as DataType, act_postreview, est_postreview
from table
) x
order by x.nams_contract_number, x.sequence

String retrieve Function in SQL Query [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am having a database with 2 columns employee and job.Job column contains character in each record.In that,I have to list the employees whose job is having last 3 characters as 'man'.I have to use only functions in SQL Query.
Use LIKE with wildcard:
SELECT *
FROM your_table
WHERE job_column_name LIKE '%man'
or using RIGHT
SELECT *
FROM your_table
WHERE RIGHT(job_column_name, 3) = 'man'
Answer For Question 4 is
SELECT *
FROM emp
WHERE SUBSTR(job,-3,3)='MAN';

Inserting data obtained via SELECT queries [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can I do this correctly?
INSERT INTO tbl_task (`Assignedby`,`userID`)
SELECT ID FROM tbl_users WHERE UserName='$_GET[u]',
SELECT ID FROM tbl_users WHERE UserName='$_GET[at]'
Assuming you want to insert one row with two columns, I think you might want this:
INSERT INTO tbl_task(`Assignedby`, `userID`)
SELECT (SELECT ID FROM tbl_users WHERE UserName='$_GET[u]'),
(SELECT ID FROM tbl_users WHERE UserName='$_GET[at]');