最近做项目遇到一个问题,外键关联查询,返回长度为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 无异常,