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

SQL help: excluding records based on another table 1

Status
Not open for further replies.

jimoblak

Instructor
Oct 23, 2001
3,620
US
I'm stumped on some SQL and would greatly appreciate guidance...

I have 2 tables. The first table is a list of all customers. The second table lists those customers that have purchased something in 2003. How can I select a list of customers that did not purchase anything?

table1.customer
customer01
customer02
customer03
customer04
customer05

table2.customersthatpurchased
customer01
customer04

The output should be:
customer02
customer03
customer05


- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
Code:
select table1.customer
from table1 left join table2
on table1.customer = table2.customersthatpurchased
where table2.customersthatpurchased is null
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top