Skip to content

Instantly share code, notes, and snippets.

@acapps
Created February 2, 2017 17:54
Show Gist options
  • Save acapps/95762e539240259c3e7aa32a9c5b8385 to your computer and use it in GitHub Desktop.
Save acapps/95762e539240259c3e7aa32a9c5b8385 to your computer and use it in GitHub Desktop.
MySQL select records that do not have relation with second table
SELECT *
FROM table_one
WHERE NOT EXISTS(SELECT *
FROM table_two
WHERE table_one.id = table_two.table_one_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment