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文执行结果有什么不一样?
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文执行结果有什么不一样?
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后面添上和去掉(+)看看结果有什么不同
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'
楼主的这种写法不熟悉. 建议用left join, 这种写法在可读性上要好点. 至于结果有什么不一样,楼主运行一下就知道了SELECT A.id, A.name FROM A LEFT JOIN B ON A.id=B.id where A.id=2
对,可以按照狂狼这样的方式改成left join我和Dave一样,更喜欢用left join,熟悉而且是SQL标准