I’m sure the solution is simple, but it evades me.
A table is configured like so:
TABLE NAME = sales
Field 1 = id INT Auto Increment Primary Key
Field 2 = user_id INT NOT NULL
Field 3 = item VARCHAR(100) NOT NULL
So let’s say I’m looking for users that have purchased the following items:
- ipod
- shoes
- bicycle
How would I structure a SQL statement to return the user_id values of users who have purchased the each of the three items (the user must have purchased all three items)?
Join up views of the table for each item
Needs distinct as a user could buy many of one item.