MySQL: how to get list of fields in a table using ODBC
I am connecting to MySQL database via terminal which only has a program with ODBC connection to MySQL database. I can put queries into the program, but not directly access MySQL.
Is there a way to query the DB to get a list of fields in a table other than
select * from table
??
(not sure why, but selection returns an error)
+1
source to share
4 answers
SELECT
COLUMN_NAME
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'MyTable'
AND TABLE_SCHEMA = 'SchemaName' /* added upon Bill Karwin comment (thanks) */
More information on INFORMATION_SCHEMA in the docs .
+3
source to share