I am trying to write a query which, based on a set of IDs, gives me the latest time for that ID from another table. This is basically showing users who accessed an item. the users are stored in one table, while the access logs are stored in another.
I want to be able to provide a list of ids (where user.id in (xyx) ) and get one row representing the latest time from the accessed table. Can someone help? i have a query right now which shows an extract for all users and accesses within a time range. I think this can be modified but i cant figure it out.
AccessLog.ACCESSED as time_accessed,
AccessLog.ACCESSTYPE as access_type,
AccessLog.USERID as user_id,
USERS.Name as USERNAME
join USERS on AccessLog.USERID = USERS.id
where accessed between '2014-11-12 11:00:00' and '2014-11-25 10:00:00'
order by accessed