MySQL – How to Select Other Rows Based on One Matching Row

MySQL

I am trying to get related rows in a tag table based on one tag, where "related" means "having the same area_id". Example:

tag       area_id
--------  -------
turkey    1
stuffing  1
carrots   1
chicken   2

I want to get rows 'stuffing' and 'carrots' based on knowing 'turkey'. How might I accomplish this with one query (and/or subqueries) please?

Best Answer

Probably easiest to just do a self-join:

SELECT x.tag 
FROM tagtable x
JOIN tagtable y
    ON x.area_id = y.area_id
WHERE y.tag = 'turkey'
  AND x.tag <> y.tag