如何在MySQL中查找包含columnA和columnB的所有表?
要查找特定的列名称,请使用information_schema.columns。在这里,我使用Id代替columnA,使用Name代替columnB-
mysql> select table_name as TableNameFromWebDatabase
-> from information_schema.columns
-> where column_name IN ('Id', 'Name')
-> group by table_name
-> having count(*) = 3;这将产生以下输出。以下是具有列Id和Name的表-
+--------------------------+ | TableNameFromWebDatabase | +--------------------------+ | student | | distinctdemo | | secondtable | | groupconcatenatedemo | | indemo | | ifnulldemo | | demotable211 | | demotable212 | | demotable223 | | demotable233 | | demotable251 | | demotable255 | +--------------------------+ 12 rows in set (0.25 sec)
为了证明这一点,让我们检查其中一张表的描述。以下是查询-
mysql> desc demotable233;
这将产生以下输出。在这里,您可以看到我们有Int和Name列-
+-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | Id | int(11) | NO | PRI | NULL | auto_increment | | Name | varchar(20) | YES | | NULL | | +-------+-------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec)
热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语