mysql中的group_concat()

mysql> select * from tab1;
+----+------+
| id | c2   |
+----+------+
|  1 |    1 |
|  2 |    1 |
|  3 |    1 |
|  4 |    1 |
|  5 |    2 |
|  6 |    2 |
+----+------+

6 rows in set (0.00 sec)

mysql> select c2,group_concat(id order by id separator ',') from tab1 group by c
2;
+------+--------------------------------------------+
| c2   | group_concat(id order by id separator ',') |
+------+--------------------------------------------+
|    1 | 1,2,3,4                                    |
|    2 | 5,6                                        |
+------+--------------------------------------------+
2 rows in set (0.00 sec)

我记得ORACLE也有这样的一个函数  wmsys.wm_concat()

 

 

 

 

 

 

你可能感兴趣的:(group_concat)