
mysql数据库如何用一条语句同时查多个数据库
1个回答
2016-05-25
展开全部
1. 子查询方法
select *
from DB2.table2
where 字段 in (select table1中相应字段 from DB1.table1 where table1中相应字段=相应值)
2. 左连接方法
select table2.*
from DB2.table2 left join DB1.table1
on table1.字段 = table2.相应字段
where table2.相应字段 = 相应值;
2. 交叉连接方法
select table2.*
from DB2.table2, DB1.table1
where table1.字段 = table2.相应字段 and table2.相应字段 = 相应值;
追问
你这粘贴的也不太对啊。 比如我有DB1到DB20 ,20个数据库。 每个库都有students表。 有一个学生叫 张三。 我需要知道张三在哪个库
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询