Mysql 查询列名

#列名
select COLUMN_NAME from information_schema.columns 
where TABLE_SCHEMA='yunpiaobox_db' and table_name='t_announcement'


#列名字符串 按,分隔  
select 
GROUP_CONCAT(COLUMN_NAME separator ',') '逗号分隔',
GROUP_CONCAT(CONCAT('OLD.', COLUMN_NAME) separator ',') 'OLD.字段     逗号分隔', 
GROUP_CONCAT(CONCAT('NEW.', COLUMN_NAME) separator ',') 'NEW.字段     逗号分隔', 
GROUP_CONCAT(CONCAT(COLUMN_NAME, '=NEW.', COLUMN_NAME) separator ',') '字段=NEW.字段 逗号分隔' 
from information_schema.columns 
where TABLE_SCHEMA='yunpiaobox_db' and table_name='t_shops'
原文地址:https://www.cnblogs.com/eason-d/p/9181728.html