Answer the question
In order to leave comments, you need to log in
How to select all users with latest status (two mysql tables)?
There are two tables:
Users (id, etc.)
User statuses (userid, status, datetime) It is
required to select all users with the latest status by time. How to do it in one request?
Answer the question
In order to leave comments, you need to log in
While I came up with this, is there another option?
SELECT *
FROM users
JOIN status ON status.userid=users.id
WHERE status.datetime = (SELECT MAX(datetime) FROM status WHERE users.id = status.userid)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question