RT
https://leetcode.cn/problems/replace-employee-id-with-the-unique-identifier/solution/
select b.unique_id, a.name from Employees a left join EmployeeUNI b on a.id = b.id;
select b.unique_id, a.name from Employees a , EmployeeUNI b where a.id = b.id;
where 過濾了null
TIPS
在使用left jion時,on和where條件的區別如下:
1、 on條件是在生成臨時表時使用的條件,它不管on中的條件是否為真,都會返回左邊表中的記錄。
2、where條件是在臨時表生成好后,再對臨時表進行過濾的條件。這時已經沒有left join的含義(必須返回左邊表的記錄)了,條件不為真的就全部過濾掉。
---------------------------我的天空里沒有太陽,總是黑夜,但并不暗,因為有東西代替了太陽。雖然沒有太陽那么明亮,但對我來說已經足夠。憑借著這份光,我便能把黑夜當成白天。我從來就沒有太陽,所以不怕失去。
--------《白夜行》
浙公網安備 33010602011771號