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

MySQL连接字段结果集

2017-08-11 00:09 204 查看
使用concat("one", " ", "three") 可以连接字符串
为 one three

mysql> select concat("one", " ", "three") as num;
+-----------+
| num       |
+-----------+
| one three |
+-----------+
1 row in set (0.00 sec)


那要连接字段结果集呢?正好我就有一个这样的需求,那使用
group_concat('field name' separator ',')
函数就可以了。

mysql> select group_concat(id separator ',') as ids from users;
+-----------+
| ids       |
+-----------+
| 1,2,3,4,5 |
+-----------+
1 row in set (0.00 sec)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql select