mysql数据库如何用一条语句同时查多个数据库

2025-02-26 13:42:00
推荐回答(1个)
回答1:

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.相应字段 = 相应值;