user1638487
user1638487

Reputation: 63

Substract and compare SQL

Hi guys I have this query

UPDATE `account`.`account` SET `status` = 'Admin' 
WHERE `status` = 'User' AND `last_online`

What I'd like to do is to check the last time online and be sure that 10 minutes had passed since last time online . Any idea? Thanks

Upvotes: 0

Views: 76

Answers (2)

Sashi Kant
Sashi Kant

Reputation: 13465

Try this::

UPDATE `account`.`account` SET `status` = 'Admin' 
WHERE `status` = 'User' AND TIMEDIFF(now(),`last_online`)>600

Upvotes: 2

phatfingers
phatfingers

Reputation: 10250

Query the database for the most recent activity and then compare the dates before choosing to insert.

Upvotes: 0

Related Questions