Using NOT IN
I have the following select statement
SELECT id FROM Teams WHERE id NOT IN (SELECT TeamID FROM Rankings WHERE Rankid = 1 AND Week = 1 AND Year = 2010 AND League = 8);
This select statement should return 30-40 rows but will continue "running" until it times out. If I remove the Rankid and League conditions
SELECT id FROM Teams WHERE id NOT IN (SELECT TeamID FROM Rankings WHERE Week = 1 AND Year = 2010);
Then it runs fine but obviously returns incorrect results.
I can run the two queries fine on there own.
SELECT id FROM Teams (returns about 150 results)
SELECT TeamID FROM Rankings WHERE Rankid = 1 AND Week = 1 AND Year = 2010 AND League = 8 (returns about 115 results)
I'm at a loss on why these two queries both run fine on there own but not when I put them together using "NOT IN" specifically why the to conditional statements are giving trouble.
Subject
Written By
Posted
Using NOT IN
January 01, 2011 06:38PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.