如何在sql中使用范围获取价格范围?

Jas*_*raj 1 mysql sql oracle

我有一个具有以下结构的表.

表图像

从该表中我需要使用表中给出的范围来查找价格.

ex:
   if i give the Footage_Range1=100 means it will give the output as 0.00 and 
   if Footage_Range1=101 means the output is 2.66
   if Footage_Range1=498 means the output is 2.66
Run Code Online (Sandbox Code Playgroud)

如何编写查询以获取价格?

Ste*_*han 6

如果我正确理解您的要求,您可以尝试这样做:

SELECT
    price 
FROM 
    my_table
WHERE
    Footage_Range1 <= YOUR_RANGE
ORDER BY
    Footage_Range1 DESC
LIMIT 1
Run Code Online (Sandbox Code Playgroud)

YOUR_RANGE输入在哪里:100,101,498等

基本上,此查询将返回最接近Footage_Range1输入的较小或相等的价格.