$query = "SELECT (UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(OnlineStatus)) AS timediff FROM userStatus WHERE timediff < 28800 ";
I'll break the query down.
- (UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(OnlineStatus))
The above finds the difference in seconds between the current time and the time in a field called OnlineStatus.
"AS timediff" gives an alias to the long statement.
The query does not retrieve any records when I add "WHERE timediff < 28800"
Is this because "timediff" is calculated within the same query?
If so, how else can the query be written? Thanks.
Richie.