Suppose I have a datetime column in MySQL. How do I select all that have a datetime within 2500 seconds of the current datetime?
SELECT ALL where current_datetime - that_datetime < 2500 ...
Suppose I have a datetime column in MySQL. How do I select all that have a datetime within 2500 seconds of the current datetime?
SELECT ALL where current_datetime - that_datetime < 2500 ...
SELECT * FROM Table WHERE that_datetime > NOW() - INTERVAL 2500 SECOND
You want to do all the function calls and operation on constants as MySQL won't use indexes for fields used in any kind of expressions.
Try this ...
SELECT * from table_name
where (extract ( epoch from current_datetime )
- extract (epoch from that_datetime)) < 2500