oracle中結果集的交集、並集、差集組合查詢


 

1.交集

intersect:返回查詢結果集中的共同部分。

    SELECT student_id,student_name FROM student_table1
    INTERSECT  
    SELECT student_id,student_name FROM student_table2

2.差集
minus:返回第一個結果集中存在而第二個結果集中不存在的部分結果集。

  SELECT student_id,student_name FROM student_table1
  MINUS  
  SELECT student_id,student_name FROM student_table1

3.並集
a>  union/union all:將兩個結果集合並,合並結果沒有過濾重復內容

    SELECT student_id,student_name FROM student_table1
    UNION ALL   
    SELECT student_id,student_name FROM student_table1

b>union:將兩個結果集合並,去掉相同的部分結果集,去重

    SELECT student_id,student_name FROM student_table1
    UNION  
    SELECT student_id,student_name FROM student_table1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM