Mysql 获取具有限制的表列中特定行值之后的记录
我如何编写一个sql来告诉mysql从下面这样的表中获取接下来的五条记录(从5开始)Mysql 获取具有限制的表列中特定行值之后的记录,mysql,sql,Mysql,Sql,我如何编写一个sql来告诉mysql从下面这样的表中获取接下来的五条记录(从5开始) srt_id (this is not the auto increment column even though the value is incremented) ------ 1 2 3 4 5 6 7 8 9 10 在这里,我想6点开始,10点结束。我甚至可能想在6点、7点或8点开始。我不能用偏移量5之类的。我得从那一排开始,把其余的拿来。你能帮忙吗 所以,我试
srt_id (this is not the auto increment column even though the value is incremented)
------
1
2
3
4
5
6
7
8
9
10
在这里,我想6点开始,10点结束。我甚至可能想在6点、7点或8点开始。我不能用偏移量5之类的。我得从那一排开始,把其余的拿来。你能帮忙吗
所以,我试着:
select * from table where srt_id = 5 limit 5; //Begin at 5 and the next 5 records
我对SQL命令不是很在行,但这里的问题似乎是,您只选择了
str_id=5
的行,最终如果在str_id
列中有2个或更多值为5的列,您将得到5。也许一个半解决方案是使用str_id>=5
,如下所示,但我认为只有在确定下一行中的值不会更低的情况下,这才有效。偏移量完全相同的从该行开始,然后提取其余的为什么不能使用偏移量<代码>从表格限制5,5中选择*代码>
select * from table where srt_id >= 5 order by srt_id limit 5;