MySQL GROUP_CONCAT

MySQL cames with lot of aggregate functions. They process data from individual rows while GROUP BY is executing. Here is one example of GROUP_CONCAT:

mysql> SELECT   user_id,
         GROUP_CONCAT(id) _id,
         COUNT(1)
FROM     bets
WHERE    user_id = 99
GROUP BY user_id;
+---------+-----------------------------------------+----------+
| user_id | _id                                     | COUNT(1) |
+---------+-----------------------------------------+----------+
|      99 | 2857,2856,2858,2851,2852,2855,2853,2854 |       12 |
+---------+-----------------------------------------+----------+

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">