SELECT id
FROM mytable
WHERE cat_id = 2 AND myvalue = 'tom'
OR cat_id = 3 AND myvalue = 'jill'
OR cat_id = 6 AND myvalue = 'sally'
GROUP
BY id
HAVING COUNT(*) = 3
Thanks for the quick response! I have tried learning a little bit about the HAVING clause, but I am not sure I understand it all that well, Would any one be interested in giving a plain-dumbed-down explanation?
the GROUP BY clause collapses multiple rows into one
each row in each grouping has the same value for the grouping column(s), in this case id
so GROUP BY groups all rows with the same id into a group, and HAVING then applies a condition to the group
in this case, the condition is that there must be 3 rows in the group
in other words, if a particular id has all three conditions which were given in the WHERE clause, then that id satisfies the HAVING clause, and thus that id is returned by the query