Mysql group_concat problem
I am just trying to find out if it is possible for a MYSQL function to GROUP_CONCAT
return this data type. Here is the script
SELECT GROUP_CONCAT(marks) AS `i need only 40 int in this column` FROM marks
when i execute this query the result is shown as follows
Result required 40
Try the following:
select group_concat(m.marks) from
( select distinct marks from marks limit 40 ) m
First advice: normalize your database tables - the field should only contain one value.
Now the solution for your specific problem: MySQL has a function FIND_IN_SET
that should do what you want:
SELECT marks
FROM marks
WHERE FIND_IN_SET('40', marks)
Your syntax
SELECT GROUP_CONCAT(marks) AS `i need only 40 int in this column` FROM marks
works correctly. You give a GROUP_CONCAT(marks)
name
i need only 40 int in this column
, so it shows what you are speaking through the syntax.
"Result 40 required"
What does this mean when you are using group_concat and want to write where the labels are 40? Why not use a query like
select * from table_name where marks='40'
If group_concat is compultion then use
SELECT GROUP_CONCAT(marks) AS `i need only 40 int in this column` FROM marks where marks='40'