gpt4 book ai didi

MySQL,如何查询区间?

转载 作者:行者123 更新时间:2023-11-29 12:06:20 25 4
gpt4 key购买 nike

就像我想做一个for i循环。表:

amount value
1 1
4 10
9 11
14 12

我想要索要金额 5 得到 10。因此,“测试”结果将是:

1 => 1
2 => 1
3 => 1
4 => 10
5 => 10
6 => 10
7 => 10
8 => 10
9 => 11
10 => 11
11 => 11
12 => 11
13 => 11
14 => 12

但是 WHERE amount = 5 不起作用。如何设置间隔?

最佳答案

这是你想要的吗?

select t.value
from table t
where t.amount <= 5
order by t.amount desc
limit 1;

关于MySQL,如何查询区间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31409867/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com