[英]MySQL return the nearest higher value
I have a table of data as follows: 我有一个数据表,如下所示:
id type temp
01 ABC123 10
02 ABC123 20
03 ABC123 30
A user may supply a temp number of 18, so in this case I want to return 20, so the nearest higher temp value to that supplied. 用户可能提供的临时编号为18,因此在这种情况下,我想返回20,因此,所提供的临时编号最接近较高的临时编号。 How do I do this please.
我该怎么做。 I cannot find a matching answer / example.
我找不到匹配的答案/示例。 Thanks in advance.
提前致谢。
SELECT MIN(temp)
FROM foo
WHERE temp > &userinput;`
尝试这个
Select * from table where temp>input order by temp limit 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.