开发者

Select rows based on value between 2 fields

I have table in SQL Server 2008:

CREATE TABLE [ValueDB](
[min_price] [float] NULL,
[max_price] [floa开发者_JS百科t] NULL
) 

Now, I have this number 250, I need to select the rows where 250 is between min_price and max_price


Something as simple as this:

SELECT * from ValueDB WHERE min_price < 250 AND max_price > 250


Your pseudo-code description is 99% of what you need.

SELECT *
    FROM ValueDB
    WHERE 250 BETWEEN min_price AND max_price


SELECT *
FROM ValueDB
WHERE 250 BETWEEN min_Price AND max_Price


select * from valuedb where 250 between min_price and max_price


If I understand your question correctly, this is all you would need to return all rows where the min price is below 250 and the max price is above 250.

SELECT *
FROM [ValueDB]
WHERE [min_price] < 250 AND [max_price] > 250
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜