join on : 多表關聯
內連接 :與其他表連接
from 表1 t join 表2 s on t.字段1 =s.字段2 join 表3 n on n.字段3=t.字段1 或 from 表1 a ,表2 b,表3c where a.字段=b.字段
自連接: 與自身連接
from 表1 t join 表1 s on t.字段1 =s.字段1 s.字段1=t.字段1
外連接:左/右連接
left join on 左連接 保證左邊表的數據全部顯示 right join on 右連接 保證右邊表的數據全部顯示
全連接:保證兩邊的表的數據全部出現
full join on
union:結果集合並
要求:前后數據的列數和字段類型要一致
例:
select s.name,s.sex,t.cno from student s union select t.name,t.sex,t.cno from student t 去掉重復數據並合並 select s.name,s.sex,t.cno from student s union all select t.name,t.sex,t.cno from student t 不去掉重復數據並合並