Oracle 左串連 left join、右串連right join說明

來源:互聯網
上載者:User

標籤:

Oracle 左、右串連

+ 在等號 左邊表示右串連  擷取右表所有記錄,即使左表沒有對應匹配的記錄。

+ 在等號 右邊表示左串連  擷取左表所有記錄,即使右表沒有對應匹配的記錄。

 

例子:

select e.empno,e.name,d.deptno,d.dname,d.loc

from emp e,dept d

where e.deptno(+) = d.deptno

右串連

已知  emp表中沒有40,dept表中有40,部門編號為40的沒有員工。

使用右串連  from emp e right join dept d on e.deptno = d.deptno   right join on  和 +在等號左邊效果相同

會擷取dept表的所有記錄,即便emp中沒有對應匹配的40部門的記錄

 

select  e.empno,e.ename,s.empno mgr_no,s.ename mgr_name

from emp e,emp s

where e.mrg = s.empno(+)

已知 empno 為7839 的沒有mrg ,編號為7839的員工沒有上司

左串連

會擷取左表的所有記錄,即便右表沒有匹配的記錄

 

左串連:以左表為基準

右串連:以右表為基準

 

Oracle 左串連 left join、右串連right join說明

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.