2017-04-13 93 views
1

我有持有價值的價格範圍和收費的東西鏈接獲取費用價格之間的價格範圍內啓動價格和endprice

+-------------+-----------+-------------+ 
| start_price | end_price | fees_amount | 
+-------------+-----------+-------------+ 
|   100 |  1000 |  5.0000 | 
|  1001 |  2000 |  10.0000 | 
|  2001 |  3000 |  15.0000 | 
+-------------+-----------+-------------+ 

如果我輸入1200,然後我不會讓fees_amount表10.0000因爲1200之間1001-2000板,

請幫我MySQL查詢

回答

1

您可以使用使用BETWEEN以下查詢:

SELECT fees_amount 
FROM table_name 
WHERE 1200 BETWEEN start_price AND end_price 

另一解決方案是以下查詢:

SELECT fees_amount 
FROM table_name 
WHERE 1200 >= start_price AND 1200 <= end_price