Reputation: 1520
I need to select a price range from 0 to 50 euros.
I have this query:
SELECT * FROM products WHERE price >= 0 AND price <= 50;
Is there a better way to do it?
Upvotes: 0
Views: 14312
Reputation: 342
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'
Upvotes: 0
Reputation: 449395
There is BETWEEN
:
SELECT * FROM products WHERE price BETWEEN 0 AND 50;
but its behaviour is different. It selects values that are equal to the starting points as well, so >=
instead of >
and <=
instead of <
.
Upvotes: 8