I saw a thread last week that was similar to this, but didin't really answer my question. So, I'll try to explain my particular problem and see if anyone can help me.
I am using SQL 2000 and this is my problem. Suppose I have these 5 customers and their orders. They can order many different bats, many different resins and many different gloves. These are their orders:
Customer1
Bat_1
Bat_2
Resin_1
Resin_2
Glove_1
Glove_2
Hat_1
Hat_2
Customer2
Bat_1
Resin_1
Resin_2
Customer3
Resin_1
Customer4
Resin_1
Resin_2
Glove_1
Glove_2
Hat_1
Hat_2
Customer5
Bat_2
This is what I want to do:
Select * customers where
They bought any bat ONLY but no other items OR
they bought any bat AND any resin ONLY with no other items
Do not select customers where
They did not buy any bat
They bought resin_1 or resin_2 but not any bat
They bought any bat as well as other items
So I want to return Customer2 and
Customer5
But do not return Customer1,
Customer3, or
Customer4
My Query is like this:
Select customer.CustName,
Equipment.BaseballEquip
From Customer
Inner join Equipment on
Equipment.Cust_ID= Customer.Cust_ID
Where
BaseballEquip Like ‘Bat%’ or BaseballEquip like ‘Resin%’
But this gives me customers even if they bought something in addition to any bat or if they bought something in addition to any bat and any resin. It doesn't limit my results to my particular criteria. So I am really stumped. Can anyone out there help me?
I am using SQL 2000 and this is my problem. Suppose I have these 5 customers and their orders. They can order many different bats, many different resins and many different gloves. These are their orders:
Customer1
Bat_1
Bat_2
Resin_1
Resin_2
Glove_1
Glove_2
Hat_1
Hat_2
Customer2
Bat_1
Resin_1
Resin_2
Customer3
Resin_1
Customer4
Resin_1
Resin_2
Glove_1
Glove_2
Hat_1
Hat_2
Customer5
Bat_2
This is what I want to do:
Select * customers where
They bought any bat ONLY but no other items OR
they bought any bat AND any resin ONLY with no other items
Do not select customers where
They did not buy any bat
They bought resin_1 or resin_2 but not any bat
They bought any bat as well as other items
So I want to return Customer2 and
Customer5
But do not return Customer1,
Customer3, or
Customer4
My Query is like this:
Select customer.CustName,
Equipment.BaseballEquip
From Customer
Inner join Equipment on
Equipment.Cust_ID= Customer.Cust_ID
Where
BaseballEquip Like ‘Bat%’ or BaseballEquip like ‘Resin%’
But this gives me customers even if they bought something in addition to any bat or if they bought something in addition to any bat and any resin. It doesn't limit my results to my particular criteria. So I am really stumped. Can anyone out there help me?