December 9, 2012
Get count of columns MySQL
Question by user1868569
How can i get the count of columns in my table, searched google through, but can’t find a straight answer.
Thank you in advance.
Answer by Starx
Such information are located in INFORMATION_SCHEMA you can query a table called COLUMNS
to get the number of columns in a database.
This query will give you the column count.
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema = 'DB_NAME' AND table_name = 'TABLE_NAME'