我的问题是,有一个SQL语句并完成工作,但不是我想要的,我希望按行动,类型,城市或房间搜索,只显示人们在查询上选择的内容以及我的代码只搜索所有记录,
SQL代码:
SELECT *
FROM `inmuebles`
WHERE
action = 'sell'
OR type = 'apartment'
OR city = 'Los Angeles'
AND rooms BETWEEN 2 AND 5
感谢任何帮助
答案 0 :(得分:0)
SELECT *
FROM `inmuebles`
WHERE
(
action = 'sell'
OR type = 'apartment'
OR city = 'Los Angeles'
)
AND rooms BETWEEN 2 AND 5
答案 1 :(得分:0)
您应该将OR更改为AND,因为现在您的条件太松了。
SELECT * FROM `inmuebles`
WHERE action = 'sell'
AND type = 'apartment'
AND city = 'Los Angeles')
AND rooms BETWEEN 2 AND 5