日期:2014-05-17  浏览次数:20837 次

A表左连B表,但又要A表中a1字段的值仅包含B表中 b1字段的记录,怎么写SQL语句啊?
如上,不用再在where 条件里加一个select语句,有什么好办法吗?

------解决方案--------------------
SQL code
select * from a,b
where 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,b
where  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