select * from table_1 a left join table_2 b on a.id=b.uid where b.`type` = 2; -- 只能查出部分数据
select * from table_1 a left join table_2 b on a.id=b.uid and b.`type` = 2;; -- 可查出左表所有数据
错误原因:
错把限制表right_table的条件,从ON 子句中放到WHERE字句中的SQL及数据
select * from table_1 a left join table_2 b on a.id=b.uid where b.`type` = 2; -- 只能查出部分数据
select * from table_1 a left join table_2 b on a.id=b.uid and b.`type` = 2;; -- 可查出左表所有数据
错误原因:
错把限制表right_table的条件,从ON 子句中放到WHERE字句中的SQL及数据