Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying missing rows with outer join

Status
Not open for further replies.

JonathanHolliday

Technical User
Aug 20, 2003
9
GB
Hi,

I'm trying to identify where some records may be missing from a file using a shared key field.

For illustration tables 'movements' and 'ledger' should both have records for every movement with a key value of 'journal'

To show all details I would use sql:
select * from movements, ledger
where movements.journal = ledger.journal

I have a problem where some records are missing so I might use the code:
select * from movements,
outer ledger
where movements.journal = ledger.journal

BUT how do I show only those records with a missing ledger record (i.e. ledger.journal is null)?

Thanks,
Jonathan.
 
You can select into a temp table, then select records from the temp table where ledger.journal is null.
 
Thanks,

I tried that but got an error, I think it doesn't help dealing with multi-million row tables so I wanted an exception only solution.

I also realised that I could use the "where not exists" statement as well.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top