I have a VIEW (lots of joins) that outputs data ordered by a date ASC. Works as expected.
OUTPUT similar to:
ID date tag1 other_data
1 25-03-2011 blue fff <=
1 26-03-2011 red ggg
1 27-03-2011 pink yyy
2 25-03-2011 red yyy <=
2 26-03-2011 orange rrr
If I apply a GROUP BY ID
. For the other columns MySQL outputs the first found row of each ID. I read this somewhere in te docs.
SELECT * FROM `myVIEW`
GROUP BY `ID`
ID date tag1 other_data
1 25-03-2011 blue fff <=
2 25-03-2011 red yyy <=
Now lets add a GROUP_CONCAT(tags1
)
SELECT *,CONCAT_GROUP(`tag1`) AS `tags`
FROM `myVIEW`
GROUP BY `ID`
Since I apply the CONCAT_GROUP the results get odd. I was expecting:
ID date tag1 other_data tags
1 25-03-2011 blue fff blue,red,pink
2 25-03-2011 red yyy red,orange
The query is returning, for example:
ID date tag1 other_data tags
1 26-03-2011 red ggg blue,red,pink
2 25-03-2011 red yyy red,orange
Looks like GROUP_CONCAT no longer preserves the VIEW order. Is this normal?