0

I have 2 columns in my table:

(DATETIME)lastsendattempt
(INT)sendgap

I know I can select all rows that have a "lastsendattempt" DATETIME which is older then the current time. But, am I able to use the value of another column to select the rows that are older than the current time - that sendgap value ?

I want it all in a single query instead of getting the sendgap value in a query and then doing another one with a datetime value

Something like...

SELECT * FROM table WHERE lastsendattempt <= (2012-04-10 01:30:15)-(INT)sendgap
1

If sendgap is the number of seconds, the correct syntax is this

SELECT * FROM table WHERE lastsendattempt <= (NOW() - INTERVAL sendgap SECOND);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.