So when users are online on my website, if they go inactive for more than 15 minutes I want to set their status to idle represented by a column in my “online” table within my database, if they go inactive for more than 30 minutes I want to completely delete the row rather than update a column.
Is there a way to do this in one query? Thanks.
The only way to do this in one query is to set up a trigger on the table such that ON UPDATE it deletes any rows that are more than the inactivity deletion threshold (30 mins).
But, that’s just two queries, ultimately – it’s just the DB is executing one after you execute one.
Don’t fear multiple queries, they’re very fast!