2013年7月11日 星期四

SQL JOIN - 關聯概述

join 大致分為 inner join & outer join

inner join 是只取出有符合條件的資料

outer join 則又分 left、right 與 full outer join


left outer join 是取出左方 table 所有資料

但條件不符沒 join 到的資料列中在其右方 table部份的資料均顯示 null


right outer join 是取出右方 table 所有資料

但條件不符沒 join 到的資料列中在其左方 table部份的資料均顯示 null


full outer join 是左右兩方 table 資料全都顯示 

而沒有 join 到的部份都顯示為 null


若加入 nature join 則是會自動 join 兩個 table 中相同欄位名稱的資料

並合併為一個顯示

沒有留言:

張貼留言