Return to Snippet

Revision: 66722
at June 24, 2014 18:28 by imbraz


Initial Code
SELECT GROUP_CONCAT(COLUMN_NAME)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = '???MY_SCHEMA???' AND
	TABLE_NAME='???MYTABLE_NAME???' AND
    COLUMN_NAME NOT IN ('???COLUMNS_TO_EXCLUDE???')
ORDER BY ORDINAL_POSITION;

Initial URL
http://www.sql-ex.ru/help/select20.php

Initial Description
This will get the names of all the columns as one long string ready to use in a select statement. N.B. There is a list of column names to exclude (In this case '???COLUMNS_TO_EXCLUDE???')

Initial Title
Extract the column names of a table (so you can select many columns but exclude some)

Initial Tags
mysql

Initial Language
MySQL