Αποτελέσματα Αναζήτησης
6 Οκτ 2009 · You can use DESCRIBE: DESCRIBE my_table; Or in newer versions you can use INFORMATION_SCHEMA: SELECT COLUMN_NAME. FROM INFORMATION_SCHEMA.COLUMNS. WHERE TABLE_SCHEMA = 'my_database' AND TABLE_NAME = 'my_table'; Or you can use SHOW COLUMNS: SHOW COLUMNS FROM my_table; Or to get column names with comma in a line:
Select Data From a MySQL Database. The SELECT statement is used to select data from one or more tables: SELECT column_name (s) FROM table_name. or we can use the * character to select ALL columns from a table: SELECT * FROM table_name. To learn more about SQL, please visit our SQL tutorial.
In this tutorial, you will learn how to show columns of a table using the DESCRIBE statement and MySQL SHOW COLUMNS command.
8 Οκτ 2018 · Use SHOW COLUMNS syntax to show the columns of the table in MySQL. Use INFORMATION_SCHEMA to select and get column names from a table in MySQL using PHP. Specify the TABLE_SCHEMA to select a table of a specific database.
To get the column names of a table in MySQL, you can use the SHOW COLUMNS FROM command. SHOW COLUMNS FROM my_table; This will return a result set containing the column names of the my_table table. You can also use the DESCRIBE command to get the same information: DESCRIBE my_table;
15.7.7.6 SHOW COLUMNS Statement. SHOW [EXTENDED] [FULL] {COLUMNS | FIELDS} {FROM | IN} tbl_name. [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr] SHOW COLUMNS displays information about the columns in a given table. It also works for views.
Displaying MySQL Column Names and Values via PHP. Sometimes in a PHP page it may be useful to not only retrieve data values from a MySQL database table, but also to retrieve column names from the table. Listed below is an example of how to do this for MySQL databases using PHP.