How To Select Rows in MySQL with No Matching Entry in Another Table

Published Date Author: , Posted May 16th, 2018 at 6:08:36pm

SELECT t1.id
FROM tableOne t1
LEFT JOIN tableTwo t2 ON t1.id = t2.id
WHERE t2.id IS NULL

The “WHERE t2.id IS NULL clause” restricts the results to only those rows where the id returned from tableTwo is null.

tableTwo.id will be NULL for all records from tableOne where the id is not found in tableTwo.

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.