MySQL只返回介于starttime和starttime+x值之间的值

MySQL只返回介于starttime和starttime+x值之间的值,mysql,time,compare,datetime-comparison,Mysql,Time,Compare,Datetime Comparison,我有一种情况,在“starttime”列中存储了unix时间戳 现在,我只想选择以下记录: currentTime = time(); // unix timestamp currentTime >= startTime && currentTime <= (starttime + x) 其中x是几秒钟的动态范围。我从你的问题中了解到,你需要做的是 select * from table where xfield > UNIX_TIMESTAMP() and

我有一种情况,在“starttime”列中存储了unix时间戳

现在,我只想选择以下记录:

currentTime = time(); // unix timestamp
currentTime >= startTime && currentTime <= (starttime + x)

其中x是几秒钟的动态范围。

我从你的问题中了解到,你需要做的是

select * from table where xfield > UNIX_TIMESTAMP() and xfield <= SUM(UNIX_TIMESTAMP(),x);

谢谢你的回答,不过我想要的是:xfield>UNIX\u时间戳和UNIX\u时间戳