I have a MySQL table like so;
foo bar
1 21
23 17
31 17
23 21
19 9
23 4
31 4
3 27
51 6
31 44
23 44
31 71
What I want is to select all the unique values of bar that correspond to both 23 and 31 in the foocolumn.
i.e. for this table, I'd get the following result;
bar
17
4
44
17, 4, and 44 all get selected, since for all of those values, two rows exist that correspond to both 23 and 31 in the foo column.
Even though the values 21 and 71 in bar correspond to 23 and 31 in foo, they would not get selected, since the same value of bar isn't present on another row that would correspond to the other number.
How would I go about this?
fooandbarunique? (i.e.23 -> 17won't appear twice in the table)