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只包含左表的條件。