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()

 

 

 

 

 

 

posted on 2008-12-25 21:36  Oracle  阅读(478)  评论(0编辑  收藏  举报