I might have oversimplified my problem here: How to use MAX in MySQL?
Given a user’s log table:
TABLE: user_log
- user_log_id (PK)
- user_id (FK)
- status
- timestamp
What I need: the very last user log entry of all users that is a certain status and is at least 15 minutes old. If the user’s latest log entry is a certain status and is 15 minutes old, I need to take certain actions in my application.
How do I query this?
Assuming
timstampisdatetimetype, anduser_id,timestampuniqueIf
user_log_idis auto increment, you may selectMAX(user_log_id)instead of `MAX(timestamp).