我需要选择0到50欧元的价格范围。
我有这个问题:
SELECT * FROM products WHERE price > 0 AND price < 50;
有更好的方法吗?
答案 0 :(得分:6)
有BETWEEN
:
SELECT * FROM products WHERE price BETWEEN 0 AND 50;
但它的行为是不同的。它也会选择等于起点的值,因此>=
代替>
和<=
而不是<
。
答案 1 :(得分:0)
SELECT * FROM products WHERE price BETWEEN 0 AND 50;
答案 2 :(得分:0)
price value pass
$pricerange = explode('-', str_replace('$','',$searchValue['price_range']));
select * from tableName where model='".$searchValue['model']."' and (price BETWEEN $pricerange[0] and $pricerange[1]) and status='active'