您的位置:首页 > 数据库 > MySQL

mysql中的group_concat()

2008-12-25 21:36 323 查看
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()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: