How do I select results from table T1 where
T1.itemID = T2.itemID
and no corresponding record found in T2, i.e. found only in T1?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Like this:
The more obvious query using NOT EXISTS runs slower older versions of MySQL. Thanks @OMG Ponies for benchmarks in a newer (unspecified) version.
Here is the NOT EXISTS version:
(Explanation, to answer comments:
LEFT JOINdiffers fromINNER JOINin that if there is no row in the right table, a row is still returned in the results but with all the columns=NULL.)