How to select this..
Posted: Fri May 14, 2010 10:19 am
This is actually from a more complex problem I posted some time ago, but I have narrowed down the problem.
The actual problem is here: viewtopic.php?f=2&t=116219
I have a table with 2 columns, namely user_id and fruits.
One user can choose any number out of 100 fruits. This is stored in those 2 columns like so:
user_id | fruit
-------------------
65 | apple
65 | pear
66 | mango
66 | apple
66 | pear
67 | apple
67 | banana
How do I select a user that eats mango AND apple AND pear.
What I cannot figure out is how to check for these 3 and make sure the user_id is the same one.
The actual problem is here: viewtopic.php?f=2&t=116219
I have a table with 2 columns, namely user_id and fruits.
One user can choose any number out of 100 fruits. This is stored in those 2 columns like so:
user_id | fruit
-------------------
65 | apple
65 | pear
66 | mango
66 | apple
66 | pear
67 | apple
67 | banana
How do I select a user that eats mango AND apple AND pear.
What I cannot figure out is how to check for these 3 and make sure the user_id is the same one.