Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Separate list of present and absent in SQL table

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

--Absent
SELECT * 
FROM `users` 
WHERE NOT EXISTS (SELECT 1 FROM user_attendance WHERE user_attendance.user_id = users.user_id);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading