选择MySQL中不包含某个列的表
作者:互联网
我试图选择所有没有名为“unique”的列的表.我可以选择使用它的所有表:
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'unique'
AND TABLE_SCHEMA ='database';
是否有一种简单的方法来修改SELECT语句,以便列出所有没有该列的表?这看起来很简单,但我无法弄明白,也无法在论坛上找到答案.
谢谢
解决方法:
select
t.*
from INFORMATION_SCHEMA.TABLES as t
left join INFORMATION_SCHEMA.COLUMNS as c
on c.TABLE_NAME = t.TABLE_NAME
and c.TABLE_SCHEMA = t.TABLE_SCHEMA
and c.COLUMN_NAME = 'unique'
where c.COLUMN_NAME is null
and t.TABLE_SCHEMA = 'database'
标签:information-schema,sql,mysql,select 来源: https://codeday.me/bug/20190730/1579405.html