gpt4 book ai didi

mysql - 如何在 mySQL 数据库中查找具有两列或多列的所有表

转载 作者:行者123 更新时间:2023-11-29 02:57:15 25 4
gpt4 key购买 nike

我想在 mySQL 数据库中找到所有包含两列“zoneid”和“affiliateid”的表。

如果我使用下面的查询,它将给我包含任一列的表。我想找出具有两列的表

SELECT DISTINCT TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('affiliateid','zoneid')
AND TABLE_SCHEMA='openx';

我试过像这样写查询

SELECT DISTINCT TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('affiliateid') AND COLUMN_NAME IN ('zoneid')
AND TABLE_SCHEMA='openx';

但是没用

最佳答案

  SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME ='affiliateid' union SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE 'zoneid'

SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME ='affiliateid' union all SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE 'zoneid'

或类似于

SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%affiliateid%' union all SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%zoneid%'

关于mysql - 如何在 mySQL 数据库中查找具有两列或多列的所有表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29427388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com