select a.id, b.id
  from a, b
 where a.cn = b.cn(+)
   and b.type(+) = '1'
select a.id, b.id
  from a, b
 where a.cn = b.cn(+)
   and b.type = '1'这2段sql文执行结果有什么不一样?

解决方案 »

  1.   

    with a as(select 1 id,'a' str from dual
      union all select 2,'a' from dual
      union all select 3,'a' from dual),
    b as(select 1 id,'b' str from dual
      union all select 2,null from dual)
    select * from a,b
    where a.id=b.id(+)
      and b.str='b'b.str后面添上和去掉(+)看看结果有什么不同
      

  2.   

    第一个相当于
    select a.id, b.id 
      from a left join b 
    on a.cn = b.cn 
      and b.type = '1' 第二个相当于
    select a.id, b.id 
      from a left join b 
    on a.cn = b.cn
    where b.type = '1' 
      

  3.   


    楼主的这种写法不熟悉. 建议用left join, 这种写法在可读性上要好点.  至于结果有什么不一样,楼主运行一下就知道了SELECT A.id, A.name FROM A LEFT JOIN B ON A.id=B.id where A.id=2
      

  4.   


    对,可以按照狂狼这样的方式改成left join我和Dave一样,更喜欢用left join,熟悉而且是SQL标准