我只想在MySQL表(unix时间戳)中选择一个字段,前提是该字段大于次高7200。如何做到这一点?
我的意思是:
从时间比下一次大7200的寄存器中选择id?
TABLE寄存器:id(int_8)、时间(int_11)、描述(文本)
示例:
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);
如果我正确理解了这个问题,就应该这样做了。