bitsCN.com
如何获得mysql数据库的所有的列
SELECT COLUMN_NAME FROM `information_schema`.`COLUMNS` where `TABLE_NAME`='appStats' order by COLUMN_NAME
所有字段获取:
SELECT COLUMN_NAME FROM 'information_schema'.'COLUMNS' where 'TABLE_SCHEMA'='数据库名称' and 'TABLE_NAME'='你的表名' order by COLUMN_NAME;
或者
select * from ’information_schema‘.’columns‘ where ’table_name‘='表名‘;
笨方法:
单个获取
$re_name_1=mysql_field_name($result,1);$re_name_2=mysql_field_name($result,2);
bitsCN.com