我有一张表,其中包含价值范围和费用链接
+-------------+-----------+-------------+
| start_price | end_price | fees_amount |
+-------------+-----------+-------------+
| 100 | 1000 | 5.0000 |
| 1001 | 2000 | 10.0000 |
| 2001 | 3000 | 15.0000 |
+-------------+-----------+-------------+
如果我输入1200,那么我将不会获得fee_amount 10.0000
,因为1200
介于1001-2000
slab之间,
请帮我解决mysql查询
答案 0 :(得分: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