无法解决此问题:
想要搜索具有类别,子类别,更低价格范围和更高价格范围的产品
select * from product p join category c
ON(p.category_id=c.category_id) where p.category=? and p.sub_category_id=?
and lower_price_limit between ? and ? or upper_price_limit between ? and ?
例如:产品范围从200 to 250
到通过220 to 230
这不起作用。
由于
答案 0 :(得分:1)
您忘记在WHERE
子句中添加括号:
SELECT *
FROM product p
JOIN category c
ON p.category_id = c.category_id
WHERE
p.category = ?
AND p.sub_category_id = ?
AND (
lower_price_limit BETWEEN ? AND ?
OR upper_price_limit BETWEEN ? AND ?
)
答案 1 :(得分:0)
尝试此查询: -
select * from product p join category c
ON p.category_id=c.category_id where p.category=? and p.sub_category_id=?
and (lower_price_limit between ? and ? or upper_price_limit between ? and ?)
答案 2 :(得分:0)
select *
from product p
join category c ON p.category_id=c.category_id
where p.category=? and p.sub_category_id=? and
(lower_price_limit between ? and ? or upper_price_limit between ? and ?)