Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.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仅当值高于下一个最高值XXX时才选择_Mysql_Unix_Select_Timestamp - Fatal编程技术网

MySQL仅当值高于下一个最高值XXX时才选择

MySQL仅当值高于下一个最高值XXX时才选择,mysql,unix,select,timestamp,Mysql,Unix,Select,Timestamp,我想在MySQL表unix timestamp中选择一个字段,前提是该字段大于次高值7200。怎么做 我的意思是这样的: 从时间比下一次大7200的寄存器中选择id 表寄存器:id int_8、timeint_11、descriptionContext 例如: 1, 127586113, This is description 2, 127587399, This is description (NEXT HIGHEST) 3, 127588524, This is description (H

我想在MySQL表unix timestamp中选择一个字段,前提是该字段大于次高值7200。怎么做

我的意思是这样的:

从时间比下一次大7200的寄存器中选择id

表寄存器:id int_8、timeint_11、descriptionContext

例如:

1, 127586113, This is description
2, 127587399, This is description (NEXT HIGHEST)
3, 127588524, This is description (HIGHEST, LET'S SAY EQUAL TO NOW())

如果我正确理解了这个问题,这应该可以解决。

请添加您的表结构、示例数据和预期输出。
select id 
from registers r
where not exists 
      (select 1 from registers where time < r.time and time > r.time - 7200)
select id from registers
WHERE time = ( select min(time)
                        from registers
                        where time > 7200);