1. 程式人生 > >sql語句左外連線與右外連線的寫法

sql語句左外連線與右外連線的寫法

左外連線:

寫法一:

select b.service_gid,c.gid
 from  table1 b,table2  c 
where b.service_gid= c.gid(+)
寫法二:
select  b.service_gid,c.gid
 from  table1 as b left join table2 as c 
on b.service_gid= c.gid

右外連線:

寫法一:

select  b.service_gid,c.gid
 from  table1 b,table2  c 
where b.service_gid(+)= c.gid
寫法二:
select  b.service_gid,c.gid
 from  table1 as b right join table2 as c 
on b.service_gid= c.gid

參考地址:http://www.cnblogs.com/youzhangjin/archive/2009/05/22/1486982.html