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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple entries - maybe wrong logic

Status
Not open for further replies.

memkam

Technical User
Aug 3, 2004
40
US
SELECT DISTINCTROW T.ID, T.CustomerAccountNumber
FROM TransactionReport T, UCustomerNumbers AS U
WHERE T.CustomerAccountNumber<>U.CustomerAccountNumber;

For every record in the Transaction report, I want to ensure that a matching CustomerNumber was found in the U table. I am trying to list all the IDs in the Transaction Report table that did not have a matching CustomerAccountNUmber in the U table.

multiple IDS can have the same Account Number.

My code is listing all the instances of the transaction report table where the ID does not match - in essensce its an infinite loop - because even if the customeraccount number matches with ID1, it may not match with ID 2. WHich is OK. As long as all the IDS in the transaction report had a matchng customer account number. I could be way off over here.

Thanks for taking the time to read this!
 
SELECT DISTINCTROW T.ID, T.CustomerAccountNumber
FROM TransactionReport T
WHERE CustomerAccountNumber not in (select CustomerAccountNumber From UCustomerNumbers);


Leslie
 
Thanks Leslie! worked like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top