I have a table in my MySQL database which contains two (relevant) columns. the two columns (we'll call them foo and bar) both consist of non-unique integers.
I want to select all distinct values of "foo" which contain each of several values for "bar". For example:
foo bar
------------
12 3
15 3
15 4
17 3
I want to select all of the values of "foo" for which both of the following are true:
-there is a row where bar=3.
-there is a row where bar=4.
in this example, it would only return the value 15.
Is there a way to do this in MySQL < 4.0?
I want to select all distinct values of "foo" which contain each of several values for "bar". For example:
foo bar
------------
12 3
15 3
15 4
17 3
I want to select all of the values of "foo" for which both of the following are true:
-there is a row where bar=3.
-there is a row where bar=4.
in this example, it would only return the value 15.
Is there a way to do this in MySQL < 4.0?