0

我想在 MySQL 表(unix 时间戳)中选择一个字段,前提是大于下一个最高值 7200。怎么做?

我的意思是这样的:

SELECT id FROM registers WHERE time IS BIGGER than NEXT time BY 7200?

表寄存器:id (int_8)、time(int_11)、description(text)

例子:

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

2 回答 2

0
select id from registers
WHERE time = ( select min(time)
                        from registers
                        where time > 7200);

如果我正确理解了这个问题,应该这样做。

于 2013-09-03T17:34:30.747 回答
0
select id 
from registers r
where not exists 
      (select 1 from registers where time < r.time and time > r.time - 7200)
于 2013-09-03T07:02:44.383 回答