select * from table1 t1 left join table2 t2 on t1.id=t2.id and t2.isdelete='0' where t1.id='12345'
以上为表相连后直接加条件,此时是以左表为基准,如果满足t1.id='12345' 但t2.isdelete='0'不满足的话,左表的满足条件的数据会被查询出来,但右表的对应数据因为不满足将为空,结果如下:
select * from table1 t1 left join table2 t2 on t1.id=t2.id where t1.id='12345' and t2.isdelete='0'
以上为连接后条件加于where后的结果,此时是以左表为基准,如果满足t1.id='12345' 但t2.isdelete='0'不满足的话,左表的满足条件的数据会因为t2.isdelete='0'不满足而不会被查询出来,所以将为空,右表的对应数据也会因为不满足也将为空,结果如下: