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

Help with a sproc

Status
Not open for further replies.

kenhutchings

Programmer
Jan 11, 2005
32
0
0
GB
Hi all,

Basically What i have is 2 tables

tbl1 - Clients
tbl2 - orders

Now what I want is all the clients who havent placed an order. Can anyone show me the basics

Cheers

Ken
 
Select (columns you want from the tables)
From
Clients c
Inner Join Orders o ON c.(some ID column) = o.(some id column)
 
Actually, he is looking for clients who <b>haven't</b> placed an order.

Select * From Clients
Where [ClientID-Not sure what your identifier is] Not in (Select [ClientID-Not sure what your identifier is] From Orders)
 
Same thing translated to join:
Code:
select Clients.*
from Clients
left outer join Orders on Clients.clientID=Orders.clientID
where Orders.clientID is null

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top