Found here http://dev.mysql.com/doc/refman/5.0/en/columns-table.html
SELECT LOWER(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'Table'
Below you can see both the MSSQL and MySQL syntax for creating a dynamic query using the results of a column from the above query.
MSSQL Syntax
DECLARE @ColumnNames [nvarchar](1024) SELECT @ColumnNames = COALESCE(@ColumnNames + ', ', '') + LOWER(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Table' DECLARE @Sql [nvarchar](1024) = 'SELECT ' + @ColumnNames + ' FROM Table ' --Remember to put spaces after SELECT and before FROM EXEC(@Sql)
With this, you dynamically create your request and then execute it.
MySQL syntax
SELECT @ColumnNames := GROUP_CONCAT(LOWER(COLUMN_NAME)) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Table'; SET @Sql = CONCAT('SELECT ', @ColumnNames, ' FROM Table '); PREPARE stmt1 FROM @Sql; EXECUTE stmt1;
source share