MySQL查询表的所有列名,用逗号拼接

问题场景

在MySQL中,需要以逗号拼接一个表的所有字段

sql语句

SELECT GROUP_CONCAT(COLUMN_NAME SEPARATOR ",") FROM information_schema.COLUMNS 
WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'table_name'


转自:http://blog.csdn.net/sand_clock/article/details/74533605
posted @ 2018-01-24 16:24  Boblim  阅读(3659)  评论(0编辑  收藏  举报