This is to find the number of columns in a table.
SELECT COUNT(*) AS num_of_columns
FROM INFORMATION_SCHEMA.COLUMNS a
WHERE a.TABLE_NAME = 'tablename'
This is to get all the columns in a table.
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS a
WHERE a.TABLE_NAME = 'tablename'