Radoslav Radoslav - 4 months ago 9
PHP Question

GROUP_CONCAT() probably this function

UPDATE: I have a mysql table with following data: user, userstat, descrip

SELECT * FROM table ORDER BY user


Result of my query looks like:

USER USERSTAT DESCRIP

usr1 1 hey
usr1 2 its
usr1 3 me

usr2 3 sometext
usr2 1 someblah
usr2 2 youknow


I would like to do it this way:

USER USERSTAT DESCRIP

usr1 1 hey
2 its
3 me

usr2 1 sometext
2 someblah
3 youoknow


is there any possibility?

(working in PHP) Thank you.

Answer

Use following sql query

select user,GROUP_CONCAT(userstat) as userstats from  table  group by user.
Comments