Table users
- id – Primary Key, AI
- username – varchar (50)
Table logins
- login_time – DateTime
- member_id – int (11)
This SQL selects mid and max login_time and sorts DESC
SELECT member_id, max(login_time) as time FROM logins
GROUP BY member_id
ORDER BY time DESC
Question
How do you select and join username onto member_id for each row?
1 Answer