(+)内连外联用法
1.首先大家知道
select * from a,b 这是个左外连接
2.其次有个地方很多人也知道
select * from a,b where a.hh =b.hh 这时候其实是个内连接
3.有趣的来了
select * from a,b where a.hh =b.hh(+) 这时候加了where条件,但是由于这个(+),其实是个左外连接,(+)在哪一边,哪边就是个副表,另一边是主表,此时还意味着副表是空也没关系哦,主表有就行,所以不要一看where条件不满足,就以为查不到结果
4.麻烦的来了
select * from a,b where a.hh = b.hh(+) and a.gg = b.gg,哇,一会有(+),一会没有,此时没有的就是个普通条件,要被满足才能查!但是大局已定,这是个左外连接了
update两个表关联
update (select a.DELAY_DAYS DELAY_DAYS, b.tn_confirm tn_confirm
from tbfunduniprofitrule a
inner join tbfundproduct b
on a.prd_code = b.prd_code
where a.prd_code = 'SLU148') t
set t.DELAY_DAYS = t.DELAY_DAYS - t.tn_confirm
update tbfunduniprofitrule a
set a.DELAY_DAYS =
(select a.DELAY_DAYS - b.tn_confirm
from tbfundproduct b
where a.prd_code = b.prd_code)
where a.prd_code in ('SLU148', 'SLV896', 'SNU908');