omacron
Technical User
- Feb 5, 2002
- 149
I am write what is an easy script but for some reason I can't get it to work.
What i want to do is find all the customers that have not made sales. So here is my data:
Cust: ID Name
123 Bob
124 Mike
125 John
Sales: Bill ID
1 123
2 125
Results: ID Name
124 Mike
This is what I wrote:
select id, name
from cust
where id not in (select id from sales)
This comes up with nothing but if Run this:
select id, name
from cust
where id in (select id from sales)
Gives me the results:
Results: ID Name
123 Bob
125 John
As you can see this is the oposite to what i want. Just can't figure out why the IN would work and not the NOT IN.
thanks
What i want to do is find all the customers that have not made sales. So here is my data:
Cust: ID Name
123 Bob
124 Mike
125 John
Sales: Bill ID
1 123
2 125
Results: ID Name
124 Mike
This is what I wrote:
select id, name
from cust
where id not in (select id from sales)
This comes up with nothing but if Run this:
select id, name
from cust
where id in (select id from sales)
Gives me the results:
Results: ID Name
123 Bob
125 John
As you can see this is the oposite to what i want. Just can't figure out why the IN would work and not the NOT IN.
thanks