MySQL Show Columns
Like this blog? Consider exploring one of our sponsored banner ads...
The easiest way to get the column names of a MySQL table is the following:
SHOW COLUMNS FROM `table`
This will actually get you column/field names, type, key, null, extra and default values as well. A classic implementation of this would be to export a table to csv or something where you wanted to list the column names once at the top, then spin through the records and output them into a file.
$query = mysql_query("SHOW COLUMNS FROM `table`"); while($row = mysql_fetch_assoc($query)){ echo $row['Field'].'<br>'; }
About this entry
You’re currently reading “MySQL Show Columns,” an entry on BRADINO
- Published:
- 5.31.07 / 4pm
- Category:
- MySQL
- Tags:
No comments
Jump to comment form | comments rss [?]