我正在执行一个 mysql 查询。我要加入 4 张桌子。我希望仅当 p.location_id 不等于 0 时才将两条粗线与查询连接。我希望当 p.location_id 等于 0 时不执行它们
SELECT p. *
FROM property p, property_type pt, location l, city c
WHERE p.status =1
AND (
pt.prop_name LIKE '%dlf%'
OR p.furnish LIKE '%dlf%'
OR p.description LIKE '%dlf%'
OR p.bed LIKE '%dlf%'
OR p.term_condition LIKE '%dlf%'
OR p.bedroom LIKE '%dlf%'
OR p.property_type LIKE '%dlf%'
OR c.city_name LIKE '%dlf%'
**OR l.loct_name LIKE '%dlf%'**
)
AND p.prop_id = pt.prop_id
AND p.city = c.city_id
**AND p.location_id = l.loct_id**
ORDER BY sortnum
有什么办法可以做到这一点。