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 -- 交叉聯合