Well my problem is that have a SQL sentence and do the job but not how I want it, AND I want search by action, type, city, or rooms and just show what people select on the queries and with my code it just search all the records,
SQL code:
SELECT *
FROM `inmuebles`
WHERE
action = 'sell'
OR type = 'apartment'
OR city = 'Los Angeles'
AND rooms BETWEEN 2 AND 5
Any help with be appreciated
SELECT *
FROM `inmuebles`
WHERE
(
action = 'sell'
OR type = 'apartment'
OR city = 'Los Angeles'
)
AND rooms BETWEEN 2 AND 5
You should change OR to AND, because now your conditions are too loose.
SELECT * FROM `inmuebles`
WHERE action = 'sell'
AND type = 'apartment'
AND city = 'Los Angeles')
AND rooms BETWEEN 2 AND 5
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.