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


/ Published in: MySQL
Save to your folder(s)

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???')


Copy this code and paste it in your HTML
  1. SELECT GROUP_CONCAT(COLUMN_NAME)
  2. FROM INFORMATION_SCHEMA.COLUMNS
  3. WHERE TABLE_SCHEMA = '???MY_SCHEMA???' AND
  4. TABLE_NAME='???MYTABLE_NAME???' AND
  5. COLUMN_NAME NOT IN ('???COLUMNS_TO_EXCLUDE???')
  6. ORDER BY ORDINAL_POSITION;

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.