SQL 聯集查詢

來源:互聯網
上載者:User
use xsglgo select  * from studentselect * from cause select * from exam --聯集查詢join on (預設為inner,如果有right or left 那麼就指的是外聯,outer 可以不寫)/*1.最長見為內聯table1  inner join table2 on table1.id = table2.id  (inner 可以省略)若且唯若兩個表中都有一行符合串連條件時才會顯示 2.外聯-- 左外聯 table1 left outer join table2 on table1.id = table2.id(outer 可以省略) 查詢出table1 表中所有的項,即使table2中與之對應的不存在 -- 右外聯 table1 right outer join table2 on table1.id = table2.id(outer 可以省略) 查詢出 table2 表中所有的項,即使table2 中與之對應的不存在 -- 全外聯 table1 full outer join table2 on table1.id= table2.id (outer 可以省略) 查詢兩個表中的所有項,含表中與另一個不對應的項-- 交叉聯結 table1 cross join table2 (沒有outer 也沒有 on,可以用where ) 返回第一個表的每一行與第二表的所有行組成的表*/select student.id,student.name,student.class, exam.grade from student inner join exam on student.id = exam.stu_id -- 內聯select student.id,student.name,student.class,exam.grade from student left outer join exam on student.id = exam.stu_id -- 左外聯select student.id,student.name,student.class,exam.grade from student right outer join exam on student.id = exam.stu_id--右外聯select student.id,student.name,student.class,exam.grade from student cross  join exam where student.id = exam.stu_id -- 交叉聯合

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.