Αποτελέσματα Αναζήτησης
The more flexible way to get a list of columns in a table is to use the MySQL SHOW COLUMNS command. SHOW COLUMNS FROM table_name; Code language: SQL (Structured Query Language) ( sql ) To show the columns of a table, you specify the table name in the FROM clause of the SHOW COLUMNS statement.
6 Οκτ 2009 · 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:
8 Απρ 2024 · MySQL offers simple methods to retrieve column names from tables. Using DESCRIBE statement. Using INFORMATION_SCHEMA.COLUMNS Statement. Using SHOW COLUMNS FROM Command. Using DESCRIBE statement to Get Column Names. To get column names, we mainly use the DESCRIBE statement.
SELECT what_to_select. FROM which_table. WHERE conditions_to_satisfy; what_to_select indicates what you want to see. This can be a list of columns, or * to indicate “all columns.” which_table indicates the table from which you want to retrieve data. The WHERE clause is optional.
FROM db_name syntax is db_name.tbl_name. These two statements are equivalent: SHOW COLUMNS FROM mytable FROM mydb; SHOW COLUMNS FROM mydb.mytable; The optional EXTENDED keyword causes the output to include information about hidden columns that MySQL uses internally and are not accessible by users.
7 Ιουλ 2015 · You can get it with: SELECT COLUMNS.COLUMN_NAME FROM information_schema.COLUMNS WHERE COLUMNS.table_schema='yourschema' and TABLE_NAME='yourtable' ORDER BY COLUMNS.ORDINAL_POSITION LIMIT 3;
29 Σεπ 2011 · You need to join information_schema.tables and information_schema.columns together to get the list of tables and their columns' details. information_schema.columns not only shows detail about tables but also views.