//取所有列名
$columnnamesql="select COLUMN_NAME from information_schema.COLUMNS where table_name = 表名";
...
$strcolumn='';
foreach($columnname as &$v){
$strcolumn.=$v['COLUMN_NAME'].',';
}
unset($v);
//列名后有逗号
$strcolumn=str_replace("不要的列名,","",$strcolumn);
$strcolumn=substr($strcolumn,0,-1);
$sql="select $strcolumn from 表名";