The best way is to use the INFORMATION_SCHEMA metadata virtual database. Specifically the INFORMATION_SCHEMA.COLUMNS table...
SELECT `COLUMN_NAME`
FROM `INFORMATION_SCHEMA`.`COLUMNS`
WHERE `TABLE_SCHEMA`='yourdatabasename'
AND `TABLE_NAME`='yourtablename';
It's VERY powerful, and can give you TONS of information without need to parse text (Such as column type, whether the column is nullable, max column size, character set, etc)...
Oh, and it's standard SQL (Whereas SHOW ...
is a MySQL specific extension)...
For more information about the difference between SHOW...
and using the INFORMATION_SCHEMA
tables, check out the MySQL Documentation on INFORMATION_SCHEMA
in general...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…