mysql实现行拼接、列拼接

举例:有t_person表如下:

一、mysql行拼接:

拼接某一行:

无分隔符:select   CONCAT(id,idcard,`status`,content)   from  t_person    

有分隔符:select   CONCAT_WS(',',id,idcard,`status`,content)   from  t_person 

二、列拼接,最实用的功能是快速取一个大表的所有列名。

SELECT   GROUP_CONCAT(COLUMN_NAME SEPARATOR ',')  FROM information_schema.`COLUMNS`  WHERE TABLE_NAME = 't_person'   group by TABLE_NAME

原文地址:https://blog.csdn.net/boyheroes/article/details/88944086
原文地址:https://www.cnblogs.com/jpfss/p/11245038.html