sql find missing values between two tables

-- Returns missing my_table1 ID in my_table2 
SELECT DISTINCT t1.* FROM my_table t1
LEFT OUTER JOIN my_table2 t2
ON t1.ID = t2.ID
WHERE t2.ID is null;
-- Or:
SELECT t1.* FROM my_table1 t1 WHERE NOT EXISTS 
   (SELECT ID FROM my_table2 t2 WHERE t2.ID = t1.ID);
-- Or:
SELECT t1.* FROM my_table1 t1 WHERE t1.ID NOT IN 
   (SELECT ID FROM my_table2 t2 WHERE t2.ID = t1.ID);

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source