I have this table in the mqsql database
create table datedemo(logintime timestamp,updatedtime timestamp);
updatedtime gives the last time the user was active , i want execute a query
such that if the difference between the updatedtime and now() time is greater than some value say (1000 seconds)
below query gives the difference in timestamp , but i want to delete the rows , please help
SELECT NOW(), updatedtime, NOW() - updatedtime AS diff
FROM datedemo
HAVING diff IS NOT NULL;
However, I think that it would be better to store expiration time not update time. I mean at update you insert not timestamp but TIMESTAMPADD(SECOND, 1000, NOW()) . This way you do the math once and when it comes to checking you issue just:
I think that it would be more efficient.