> You can restrict the results by means of a subquery. Lets assume you have
> a
[quoted text clipped - 48 lines]
>>
>> Thanks
No, customer #305 won't be returned if he has ever received product X,
regardless of what other products he has received. The query will only
return a row from the Customers table if the subquery returns no rows; this
is what the NOT EXISTS predicate means. So if customer #305 has received
product X his row won't be returned because the subquery will return at least
one row and consequently the NOT EXISTS predicate will be False. Whether
he's received any other products is irrelevant as the subquery concerns
itself only with product X. He may have been stuffed to the gills with a
dozen other products, he still won't be returned. Which is what I think you
were saying you wanted in you original post.
If customer #305 has never received product X on the other hand, the
subquery won't return any rows so the NOT EXISTS predicate will be True and
he will be returned. Again what other products he may or may not have
received are irrelevant.
Ken Sheridan
Stafford, England
> So if I want to see which customers did NOT receive product X and I have
> customer #305 that has received product X and also product Y, with your
[quoted text clipped - 55 lines]
> >>
> >> Thanks
Jason - 08 May 2008 21:05 GMT
I see what you're saying now.
Thanks for the advice, it seems to work well this way.
> No, customer #305 won't be returned if he has ever received product X,
> regardless of what other products he has received. The query will only
[quoted text clipped - 89 lines]
>> >>
>> >> Thanks
Ken Sheridan - 08 May 2008 21:26 GMT
It should do; it’s the standard solution to this sort of problem.
Ken Sheridan
Stafford, England
> I see what you're saying now.
> Thanks for the advice, it seems to work well this way.