好吧,我的问题是有一个 SQL 语句并完成工作,但不是我想要的,我想按操作、类型、城市或房间搜索,只显示人们在查询中选择的内容,并使用我的代码搜索所有记录,
SQL 代码:
SELECT *
FROM `inmuebles`
WHERE
action = 'sell'
OR type = 'apartment'
OR city = 'Los Angeles'
AND rooms BETWEEN 2 AND 5
任何帮助不胜感激
好吧,我的问题是有一个 SQL 语句并完成工作,但不是我想要的,我想按操作、类型、城市或房间搜索,只显示人们在查询中选择的内容,并使用我的代码搜索所有记录,
SQL 代码:
SELECT *
FROM `inmuebles`
WHERE
action = 'sell'
OR type = 'apartment'
OR city = 'Los Angeles'
AND rooms BETWEEN 2 AND 5
任何帮助不胜感激
SELECT *
FROM `inmuebles`
WHERE
(
action = 'sell'
OR type = 'apartment'
OR city = 'Los Angeles'
)
AND rooms BETWEEN 2 AND 5
您应该将 OR 更改为 AND,因为现在您的条件太宽松了。
SELECT * FROM `inmuebles`
WHERE action = 'sell'
AND type = 'apartment'
AND city = 'Los Angeles')
AND rooms BETWEEN 2 AND 5