如何獲得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);