Oracle表與表之間的串連方式(內串連:inner join 、外串連 全串連: full outer join、左串連:left outer join 、右串連:right outer join、自然串連:natural join)

來源:互聯網
上載者:User

標籤:串連方式   欄位名   比較   欄位   記錄   右外串連   外串連   方式   使用   

 1 --內串連:INNER JOIN 它表示返回兩個表或記錄集串連欄位的匹配記錄,表示兩個表中相互包含的部分 2 select * from student inner join sc on student.sno=sc.sno;
 
3 --外串連(全串連):包含左、右兩個表的全部行,不管另外一邊的表中是否存在與它們匹配的行.不合格,以空值代替。 4 --全串連:表示兩個表組合在一起,左右不相匹配時使用空值替換 5 select * from student full outer join sc on student.sno=sc.sno;
 
6 --左串連:左外串連又叫左串連,意思是包含左邊表所有記錄,右邊所有的匹配的記錄,如果沒有則用空補齊.換句話說就是,列出左邊表全部的,及右邊表合格,不合格以空值代替. 7 select * from student left outer join sc on student.sno=sc.sno;
 
8 --右串連:右外串連又叫右串連,意思是包括右邊表所有記錄,匹配左邊表的記錄,如果沒有則以空補齊.換句話說,與左串連一樣,列出右邊表全部的,及左邊表合格,不合格用空值替代. 9 select * from student right outer join sc on student.sno=sc.sno;

10 --自然串連:在串連條件中使用等於(=)運算子比較被串連列的列值,但它使用挑選清單指出查詢結果集合中所包括的列,並刪除串連表中的重複列。其實只要欄位名相同,資料類型不同,也可以做自然串連。11 select * from student natural join sc;

 

Oracle表與表之間的串連方式(內串連:inner join 、外串連 全串連: full outer join、左串連:left outer join 、右串連:right outer join、自然串連:natural 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.