I've got a table for storing customers choices regarding products.
It stores a customer number, product number and whether it's a yes or no thanks on the product. We're storing yes/no because the customer must make a choice on all products so that we can check if they've made all choices.
Customer | Product | Status
---------------------------
12345 | 1 | 0
12345 | 2 | 1
12345 | 3 | 1
12345 | 4 | 0
12345 | 5 | 1
23456 | 1 | 1
23456 | 2 | 0
23456 | 3 | 1
23456 | 4 | 1
23456 | 5 | 0
What I want to do is check which customers has chosen a specific set of products.
That could be something like select * from choices where product = 1 and product = 3 group by customer
but then I must also query products with status = 1
Is there a way to solve this in a query or will I have to resort to a couple of calls to some PHP?