Reputation: 2867
My table is composed of multiple columns, including unixtimestamp:
CREATE MyTable(
id INT NOT NULL AUTO_INCREMENT,
...
timeStart INT(11)
)ENGINE=MyISAM;
New items are inserted continually to this table.
I need to return all items with a timestamp > (MAX(startTime)-X_duration)
I am interested to write a single and optimal query to achieve it.
MAX(timeStart) as maxTime
, than select all records greater than in where clause.I am interested if there are better and more efficient solutions?
Upvotes: 1
Views: 124
Reputation: 263893
SELECT *
FROM tableName
WHERE timeStart > (SELECT MAX(timeStart) + INTERVAL -1 SECOND FROM tableName)
Upvotes: 2