Mysql 查询是否存在多个表

Mysql 查询是否存在多个表,mysql,Mysql,我需要编写一个查询,如果我请求的所有表都存在,它将返回结果。我知道这是存在的: show tables like 'user' 只是不知道如何为多个表扩展它。我知道这是无效代码,但类似于 show tables like 'user' AND show tables like 'site' AND ... 谢谢大家! 我知道这在MySQL中有效。。。(只是一个例子) 我知道这在MySQL中有效。。。(只是一个例子) 嗯,我意识到这个问题。如果所有表都存在,它只返回一条记录。这将是一个更好的解

我需要编写一个查询,如果我请求的所有表都存在,它将返回结果。我知道这是存在的:

show tables like 'user'
只是不知道如何为多个表扩展它。我知道这是无效代码,但类似于

show tables like 'user' AND show tables like 'site' AND ...

谢谢大家!

我知道这在MySQL中有效。。。(只是一个例子)


我知道这在MySQL中有效。。。(只是一个例子)

嗯,我意识到这个问题。如果所有表都存在,它只返回一条记录。这将是一个更好的解决方案

select group_concat(table_name order by table_name) as table_list
from information_schema.tables
where table_name in ('tb1','tb2','tb3') 
and table_schema = 'your_db'
having count(*) = 3
嗯,我意识到这个问题。如果所有表都存在,它只返回一条记录。这将是一个更好的解决方案

select group_concat(table_name order by table_name) as table_list
from information_schema.tables
where table_name in ('tb1','tb2','tb3') 
and table_schema = 'your_db'
having count(*) = 3

您可以使用information_schema.tables对象-请参阅您可以使用information_schema.tables对象-请参阅堆栈溢出是一个神奇的地方。我的天啊,这个回答太快了!谢谢@elightbo:别担心。很高兴我能帮助你。问候:)堆栈溢出是一个神奇的地方。我的天啊,这个回答太快了!谢谢@elightbo:别担心。很高兴我能帮助你。问候:)
select * 
from information_schema.tables
where table_name in ('tb1','tb2','tb3') 
and table_schema = 'your_db'
having count(table_name) = 3
select group_concat(table_name order by table_name) as table_list
from information_schema.tables
where table_name in ('tb1','tb2','tb3') 
and table_schema = 'your_db'
having count(*) = 3