select
apply.*,
label.*
from
apply_month apply
left join
overdue_label label
on apply.transactionid = label.transid
where
apply.stat_month=${month}
and label.applymonth=${month}
;
select
apply.*,
label.*
from
apply_month apply
left join
(
select
*
from
overdue_label
where
applymonth=${month}
) label
on apply.transactionid = label.transid
where
apply.stat_month=${month}
;
第一个sql执行的结果行数少于第二个sql的执行结果。
原因是第一个sql where包含左表条件和右表条件,而第二个sql where只包含左表的条件。