J
junk
This is a simplified example of what is probably a simple SQL query,
but my SQL skills are too weak...
Customer table:
CustomerID
EmailAddress
Orders table:
CustomerID
ProductOrdered
There is a one-to-many relationship between Customers and Orders keyed
on the CustomerID field.
Multiple customers can have the same EmailAddress.
I want to find all unique Customer.EmailAddresses where the customer
has ordered both product A and B (i.e., where there is a related
Order.ProductOrdered="A" record and an Order.ProductOrdered="B"
record).
Similarly, I'll need to find all Customer.EmailAddresses where the
customer has ordered only product A and not product B (i.e., where
there is a related Order.ProductOrdered="A" record and there is not an
Order.ProductOrdered="B" record).
Thanks for your help!
Steve
but my SQL skills are too weak...
Customer table:
CustomerID
EmailAddress
Orders table:
CustomerID
ProductOrdered
There is a one-to-many relationship between Customers and Orders keyed
on the CustomerID field.
Multiple customers can have the same EmailAddress.
I want to find all unique Customer.EmailAddresses where the customer
has ordered both product A and B (i.e., where there is a related
Order.ProductOrdered="A" record and an Order.ProductOrdered="B"
record).
Similarly, I'll need to find all Customer.EmailAddresses where the
customer has ordered only product A and not product B (i.e., where
there is a related Order.ProductOrdered="A" record and there is not an
Order.ProductOrdered="B" record).
Thanks for your help!
Steve