开发者

Select Price range - MySQL Query

I need to select a price range from 0 to 50 euros.

开发者_StackOverflow中文版

I have this query:

SELECT * FROM products WHERE price >= 0 AND price <= 50;

Is there a better way to do it?


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 <.


SELECT * FROM products WHERE price BETWEEN 0 AND 50;


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'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜