Reputation: 11
im try to execute sql query that will check if some time (like 10 sec) past from last timestamp update in my table and chenge other table if yes.
My question is if ther is any time-stamp conditional operator that can check this? For example < , > ,=?
(I know that I can do it in to different query, but I'm try do to it in 1 query)..
Something like this
UPDATE Person SET isconnected=false
where person.email=(select from imalive where timestamp<10).
person:
email: [email protected]
name: dan
age: 20
isAlive:
email: [email protected]
lastseen: 2011-09-04 21:27:00
So at last if the person is last seen will be more then 10 sec he will go to isconnected =false.
Upvotes: 0
Views: 436
Reputation: 238296
Syntax would change slightly per database. Here's an example for SQL Server using not exists
:
update Person
set IsConnected = 0
where IsConnected <> 0
and not exists
(
select *
from IsAlive
where Person.email = IsAlive.email
and IsAlive.timestamp > dateadd(s,-10,getdate())
)
Upvotes: 2