Link to home
Start Free TrialLog in
Avatar of Jason Minton
Jason MintonFlag for United States of America

asked on

Simple Oracle SQL query help needed

I need all id's in table1 that are not in table2 after a specific date.

table1:
id

table2:
date
id

I need to know all of the id's in table 1 that do not appear in table2 with a date greater than 1/1/07 for example.

This is an Oracle db.
Avatar of mbizup
mbizup
Flag of Kazakhstan image

SELECT Table1.ID
FROM Table1 LEFT JOIN Table2 ON Table1.ID = Table2.ID
WHERE Table2.ID IS NULL AND Table1.Date > [SomeDate]
SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jason Minton

ASKER

Here were my results:
mbizup: no results returned
slightwv:  seems to return opposite of what I want.  I probably could just reverse it and get what I want.
sathyagiri:  this seems to work.

Thank you...
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

>>seems to return opposite of what I want.

oops.  Yes, just reverse the minus and it should work.

You should run an explainn plan on both to see which works best in your database.   My money is on the 'minus' query.
Thanks I will...  This is just a one time (manual) data extract though, so not a big deal really.