当前位置: 代码迷 >> Oracle管理 >> A表左连B表,但又要A表中a1字段的值仅包含B表中 b1字段的记录,如何写SQL语句啊
  详细解决方案

A表左连B表,但又要A表中a1字段的值仅包含B表中 b1字段的记录,如何写SQL语句啊

热度:58   发布时间:2016-04-24 05:37:59.0
A表左连B表,但又要A表中a1字段的值仅包含B表中 b1字段的记录,怎么写SQL语句啊?
如上,不用再在where 条件里加一个select语句,有什么好办法吗?

------解决方案--------------------
SQL code
select * from a,bwhere a.id=b.id(+) and instr(a1,b1)>0
------解决方案--------------------
SQL code
select a.*  from a left join b    on a.a1 = b.b1 where b1 is not null;
------解决方案--------------------
SQL code
select * from a,bwhere  a1 not in (select b1 from b where a.id=b.id(+))
------解决方案--------------------
select a.* from a left join b on a.a2 = b.b2 and a.a1<>b.b1
  相关解决方案