我有桌子
+------------+------------+--------------+---------------+
| lbs | tx | ca | ny |
+------------+------------+--------------+---------------+
| 1 | 20 | 30 | 40 |
+------------+------------+--------------+---------------+
| 2 | 25 | 35 | 45 |
+------------+------------+--------------+---------------+
| 3 | 30 | 40 | 50 |
+------------+------------+--------------+---------------+
我想让MySQL查询根据两个变量获得最接近的最高数字。就像是
SELECT * FROM table WHERE state = '$state' AND lbs = '$lbs' NEAREST HIGHEST
如输入1.3磅,则选择2磅
这可能吗?
最佳答案
很简单的 :
SELECT * FROM table WHERE state = '$state' AND lbs >= '$lbs' LIMIT 1
关于php - MySQL查询以搜索最接近的最高编号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31558152/