接上篇文章
上面两个SQL以标准SQL语法来描述可能更容易理解:
SQL1:
SELECT COUNT(*)
FROM econtract.cm_contracts_single_v smcon
LEFT JOIN base.bas_regions_v reg ON reg.region_id = smcon.region
AND reg.enable_flag = 'Y'
AND reg.region_type = 2
LEFT JOIN base.bas_regions_v off ON off.region_id = smcon.office
AND off.enable_flag = 'Y'
AND off.region_type = 3;
SQL2:
SELECT COUNT(*)
FROM econtract.cm_contracts_single_v smcon
LEFT JOIN base.bas_regions_v reg ON reg.region_id = smcon.region
LEFT JOIN base.bas_regions_v off ON off.region_id = smcon.office
WHERE reg.enable_flag = 'Y'
AND off.enable_flag = 'Y'
AND off.region_type = 3
AND reg.region_type = 2;
二者的区别显而易见。