最近做項目遇到一個問題,外鍵關聯查詢,返回長度為1,但是值為 All elements are null沒數據。
有兩張表,分別為a表有數據,b表無數據。
select b.* from a as a left join b as b on b.a_id = a.id 發生異常
修正sql select b.* from a as a left join b as b on b.a_id = a.id where b.id is not null就可以避免這種情況。
select a.* from a as a left join b as b on b.a_id = a.id 無異常,