227 Mysql查询指定库某个表得所有字段,以逗号分隔

这一种很好用

select group_concat(COLUMN_NAME separator ',') from information_schema.COLUMNS where table_schema='your_database' and table_name = 'your_table_name';

或者

SELECT
        GROUP_CONCAT( column_name SEPARATOR ',' ) 
FROM
        information_schema.COLUMNS 
WHERE
        column_name <> 'con_id' 
        AND table_name = 'contract' 
GROUP BY
        table_name

猜你喜欢

转载自blog.csdn.net/phpstory/article/details/108196527