类似于How to find all the tables in MySQL with specific column names in them?我想找到包含 2 个特定列的表格,而不是“或”。
我尝试过使用 AND 进行组合,但没有成功。
例如,我想在数据库中搜索包含 CategoryID 和 LotNumber 列的特定表。
最佳答案
通过information_schema.columns
表,按表对匹配的列进行分组,并仅返回编号等于 2 的列:
SELECT table_name
FROM information_schema.columns
WHERE (column_name = 'colname1' OR column_name = 'colname2')
[AND table_schema = 'dbname']
GROUP BY table_name
HAVING count(*) = 2;
关于mysql - 如何在 MySQL 中找到包含 2 个特定列的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40051862/