Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 获取具有限制的表列中特定行值之后的记录_Mysql_Sql - Fatal编程技术网

Mysql 获取具有限制的表列中特定行值之后的记录

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之类的。我得从那一排开始,把其余的拿来。你能帮忙吗 所以,我试

我如何编写一个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之类的。我得从那一排开始,把其余的拿来。你能帮忙吗

所以,我试着:

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;