oracle中各類鏈接事例,left join、right join、full join

Aspa

  

B3d

 

--內鏈接 把匹配的信息所有查出來
select * from t_wdx_a a inner join t_wdx_b b on a.id = b.id; 

 

--左鏈接 包含左邊表全部記錄,右邊全部的匹配的記錄,若是沒有則用空補齊(簡寫的時候+在右邊)
select * from t_wdx_a a left join t_wdx_b b on a.id = b.id;
select * from t_wdx_a a left outer join t_wdx_b b on a.id = b.id;
select * from t_wdx_a a,t_wdx_b b where a.id = b.id(+);

 

--right join 右鏈接 包括右邊表全部記錄,匹配左邊表的記錄,若是沒有則以空補齊(簡寫的時候+在左邊)
select * from t_wdx_a a right join t_wdx_b b on a.id = b.id;
select * from t_wdx_a a, t_wdx_b b where a.id(+) = b.id;

 

--full join  全鏈接 意思是左右表全部的記錄所有顯示出來
select * from t_wdx_a a full join t_wdx_b b on a.id = b.id;
 
相關文章
相關標籤/搜索