Is there a way to grab the columns name of a table in mysql? using php
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
in mysql to get columns details and table structure by following keywords or queries
1.
DESC table_name
2.
DESCRIBE table_name
3.
SHOW COLUMNS FROM table_name
4.
SHOW create table table_name;
5.
EXPLAIN table_name
I needed column names as a flat array, while the other answers returned associative arrays, so I used:
$col_names now equals:
The following SQL statements are nearly equivalent:
Reference: INFORMATION_SCHEMA COLUMNS
The
mysql_list_fields
function might interest you ; but, as the manual states :You may also want to check out
mysql_fetch_array()
, as in: