How to select rows with no matching entry in another table

Here’s a little tip that I found very useful for a recent project that I was doing.

When using MySql, some time you may want to query the rows of a table that don’t match another table. Well Ive got the perfect solution for you!


SELECT t1.ID
FROM Table1 t1
LEFT JOIN Table2 t2 ON t1.ID = t2.ID
WHERE t2.ID IS NULL

Just change t1 and t2 to mach you table names!

Leave A Reply Here

  Username [*]

  Email Address [*]

  Website

Subscribes to this post comments updates

Please Note: All comments maybe under going moderation so there is no need to resubmit the comments. it will appeared when admin approved it, feel free to subscribes to the post comments rss to stay update