mysql 字符串连接 concat、gropu_concat用法

来源:互联网 发布:淘宝外国模特 编辑:程序博客网 时间:2024/05/16 18:18
select group_concat(id) from streat_temp where id not in (45383,19979);

输出结果:

28372,28373,28385,28370,28367,28395,28386,28378,28368,28387,28371,28369,28380,28394,28379,28388,28392,28377,28404,28384,28419,28375,28376,28405,28381,28374,28383,28393,28420,28403,28382,45338,45305,45339,45368,45306,45307,45304,45340,45381,45435,45425,45407,45445,45436,45463,45423,45424,45447,45406,45446,45461,45464,45409,45422,45479,45437,45478,45382,45462,45408,45448,45480,31677,31673,31676,31682,31679,31678,31684,31675,31681,31680,31685,31672,31674,31683,31719,31795,31796,31730,31751,31776,31835,31731,31717,31732,31837,31815,31718,31777,31753,31752,31816,31836,31794,31775,31754,19917,19916,19903,19904,19870,19884,19894,19918,19906,19882,19883,19893,19927,19871,19869,19905,19895,19934,19943,19978,19953,19954,20012,19989,20013,20000,19963,19987,19964,19988,19932,19965,19942,19933,19952,20014,35304,35298,35297,35308,35300,35302,35299,35303,35326,35380,35382,35357,35339,35325,35327,35319,35328,35338,35405,35315,35404,35406,35320,35358,35379,35337,35314,35313,35321,35381,35407,35359,35356

结论:通过使用group_concat可以将返回的结果集指定的列连接成一个字符串

0 0