Mysql again, group and display the rest of the rows

I have a table:

id, day, user, value, active

And now I get a SELECT day from the user ppl GROUP BY

but! I want all days to be on the same line, not just

eg

day: 1,2,3,4,5,6,7,8,9 ... user: myusername

Is it possible?

Yes,

SELECT user, GROUP_CONCAT(day) day FROM ppl GROUP BY 1; 

The answer to my question, but I have the following, last

Here is the result of the request http://screenshooter.net/0562655/24_05_2012__22_37_09

how to change

 row 3 from 8,9,10 to 8-10 row 5 from 21,22,23,24,28,29,30 to 21-24,28-30 row 6 from 17,21,22,23,24,25 to 17,21-25 

?

0
source share
1 answer
  SELECT user, GROUP_CONCAT(day) day FROM ppl GROUP BY 1; 
+1
source

Source: https://habr.com/ru/post/916673/


All Articles