I have two tables, Users and Visitors. In Users, I have all the user information and in Visitors I put the login results. Every time a user logs in, a new record goes into Visitors with the user_id and datetime.
I want to select all the users with the datetime of the last login. How can I do this?
try using subquery in the select
for example:
select u.name,(select datetime from visitors v where u.id_user = v.id_user order by datetime desc limit 1) as lastlogin_datetme from users u;