【转载】mysql查询某字段的多条结果展示成按逗号隔开
mysql查询某字段的多条结果显示成按逗号隔开
有表:tt
字段:
id tel
1 13578945620
2 13578945621
3 13578945622
4 13578945623
5 13578945624
查询tel字段,我希望出现的结果是这样的:13578945620,13578945621,13578945622,13578945623,13578945624
求SQL语句
有表:tt
字段:
id tel
1 13578945620
2 13578945621
3 13578945622
4 13578945623
5 13578945624
查询tel字段,我希望出现的结果是这样的:13578945620,13578945621,13578945622,13578945623,13578945624
求SQL语句
select group_concat(tel) from tt
使用GROUP_CONCAT函数。
select GROUP_CONCAT(查询的字段 separator ';') from table
select group_concat(tel separator',') from tt

浙公网安备 33010602011771号