LEFT JOIN 的 ON 條件與 WHERE 條件的差別
我有兩個 Table,
第一個 Table 是『學生檔案』,
第二個 Table 是『每個課程的成績』,
我要給大明一份與其他同學的分數比較文件,
所以以第二個 Table 當主 Table,
第一個 Table 當 Left Join 的 Table
在 on 的條件指定下為第一個 Table 的『Student_Name = 大明』,
如此大明就能比較與其他同學的分數。
假如把『Student_Name = 大明』以 Where 條件指定,
雖然 Left Join 會保留第一個 Table 的 7 筆資料,
但 Where 『Student_Name = 大明』後,就只會留下大明的資料了。
留言
張貼留言