跨数据库left join的问题??
需要跨数据库left join 俩个表a,b。。数据库是不同类型的数据库oracle,mssql
select * from a left join b on a.id=b.id where b.col1="xxx"
和
select * from a left join b on a.id=b.id where a.col1="ccc"
这俩个sql要怎么实现呢???
我的思路是比如:select * from a left join b on a.id=b.id where b.col1="xxx"
先查询 select b.id from b where b.col1="xxx"
然后在 select * from a where a.id in (b.id)
思路看起来可行,但是好像与语句顺序相反。而且如果b.id很多的话,导致 where a.id in (b.id) 会很长,in查询好像也有长度限制,不过可以使用for循环解决,比较麻烦些。。
如果先执行select * from a left join b on a.id=b.id 再根据where语句过滤 ,好像俩面会加载好多无用的记录集。。
有没有更好的思路呢??