i have a database with 100 users and their login time (for 1 user there are 10000 rows). so how can i pick 3 users (by their userid) and then get only last time they logged in
(id, userid, timestamp)
SELECT userid,timestamp FROM users WHERE userid='22' ORDER BY id DESC LIMIT 1 ;
SELECT userid,timestamp FROM users WHERE userid='15' ORDER BY id DESC LIMIT 1 ;
SELECT userid,timestamp FROM users WHERE userid='42' ORDER BY id DESC LIMIT 1 ;
i tried also GROUP BY but is not showing last timestamp for each user
SELECT userid,timestamp FROM users WHERE userid IN (22,15,42)' GROUP BY userid ORDER BY id DESC LIMIT 3 ;