I am trying to separate table results into those who are present and absent. For example, I have this users table here and user_attendance table here. Those users in the user_attendance table were present and I am trying to use the query below to show those who are not present/absent in the user_attendance table:
SELECT *
FROM `user_attendance`
INNER JOIN users on users.user_id = user_attendance.user_id
WHERE users.user_id IS NULL;
Help would be greatly appreciated. Thank you.
>Solution :
--Absent
SELECT *
FROM `users`
WHERE NOT EXISTS (SELECT 1 FROM user_attendance WHERE user_attendance.user_id = users.user_id);