我似乎无法弄清楚为什么WHERE中的AND语句被忽略了?
MYSQL查询
SELECT
HomeStatus.Completed
FROM HomeInfo
LEFT JOIN HomeSubdivision ON HomeSubdivision.HomeSubdivisionID = HomeInfo.SubdivisionID
LEFT JOIN HomeSection ON HomeSection.HomeSectionID = HomeInfo.SectionID
LEFT JOIN HomeStatus ON HomeStatus.HomeStatusID = HomeInfo.HomeStatusID
WHERE TRIM(CONCAT(IFNULL(TRIM(HomeInfo.HomeNumber), ''), " ", IFNULL(TRIM(HomeInfo.HomeStreet), ''), " ", IFNULL(TRIM(HomeInfo.HomeStreetType), ''), " ", IFNULL(TRIM(HomeInfo.HomeStreetUnit), ''))) LIKE '%lake%' OR HomeSubdivision.SubdivisionName LIKE '%lake%'
AND HomeStatus.Completed = 0
AND HomeStatus.Reference = 0
AND HomeStatus.Cancel = 0
GROUP BY SectionName
ORDER BY SubdivisionName, LENGTH(SectionName), SectionName ASC
结果:
Completed
1
1
1
1
0
1
0