我目前正在使用以下查询从单个mysql表中获取列名
SELECT COLUMN_NAME as column_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'product'
AND COLUMN_NAME
NOT IN ('ean','jan','isbn','mpn','upc');
如何从多个表中获取列名?对于这种情况,有没有像JOIN这样的选项?
答案 0 :(得分:0)
SELECT COLUMN_NAME as column_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE (TABLE_NAME = 'product' AND COLUMN_NAME NOT IN ('ean','jan','isbn','mpn','upc'))
OR (TABLE_NAME = 'other_table' AND COLUMN_NAME NOT IN ('something_else'))
答案 1 :(得分:0)
使用以下查询
SELECT COLUMN_NAME as column_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME in ('product' , 'other table name')
AND COLUMN_NAME
NOT IN ('ean','jan','isbn','mpn','upc');