Click here to Skip to main content
16,019,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 tables and want to know if since a user last login there was an update on a table.

I am using a table for dataentry and another to keep the time stamp of all the user last login

How can I check if the time stamp of each row in dataentry is more recent or not since the last login

I have tried this and I am managing to get the difference, if the answer is negative the entry has been done after the user last logged in, and vice versa if positive.

I need only to get the -ve rows
SQL
SELECT TIMESTAMPDIFF(second, ts, tsLog) as TotalSeconds FROM dataentry,userLogs
Posted
Updated 10-May-13 9:25am
v2
Comments
Zoltán Zörgő 10-May-13 16:01pm    
Please provide structure of both tables.
datt265 11-May-13 4:01am    
dataentry table --> id, event, ts (ts is timestamp)
userLogs table --> userName, tsLog (tsLog is a timestamp when the user logged last)
Zoltán Zörgő 11-May-13 5:18am    
To query what you need, you need to be able to link (reference) these tables by user. But with your current structure you can not.
You need something like this:
dataentry table --> id, event, ts, userId,
userLogs table --> userid, tsLog
users --> userId, Username, other fields related to the user


Or at least:
dataentry table --> id, event, ts, userName
userLogs table --> userName, tsLog

Without something like this it is impossible.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900