I have a simple lookup table (MySQL): id1 int 11 id2 int 11 Example data is: id1 / id2 1 / 1 1 / 2 1 / 3 2 / 2 2 / 3 2 / 4 What I would like is to find the value of id1 where the values of id2 match a set of values (like 2, 3 AND 4). How can I get the id1 of 1 returned given a set of values (2, 3, 4) to match against id2?
If I understand the question, you want an IN. Using your example data i created this table (dp_112208): +------+------+ | id1 | id2 | +------+------+ | 1 | 1 | | 1 | 2 | | 1 | 3 | | 2 | 2 | | 2 | 3 | | 2 | 4 | +------+------+ Code (markup): And using the query: SELECT id1 FROM dp_112208 WHERE id2 IN (2,3,4); Code (markup): I get this result: +------+ | id1 | +------+ | 1 | | 1 | | 2 | | 2 | | 2 | +------+ Code (markup): I hope this helps!