如何在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 生日广州男生祝福语简短