Thank you! I only occasionally write SQL and each time have to thunk hard as I have got rusty. This article always helps. I am hoping you still monitor it as I have a question that I cannot solve. I will try to explain using your recipes example.

I want a list of all Recipes with a given Ingredient lets say ‘Butter’ in addition I want any additional Recipes that have ‘Butter’ in their name. I know this sounds bonkers since one can reasonable expect Butter Chicken to have butter in the recipe. But my real example is where items have been tagged and they may not have been tagged with ‘butter’ but it may be in the name of the item.

i can get the list of items using a UNION query but i don’t know how to make the results unique by which I mean the equivalent of a unique list of recipes. I think I need to have a query and a subquery but I can’t work out how. At the risk of boring you to death here is my query:

[code]
SELECT events.id, events.title, interests.name as Interest
FROM events
INNER JOIN event_interests on events.id=event_interests.event_id
INNER JOIN interests on interests.id = event_interests.interest_id
WHERE lower(events.title) like ‘%forro%’ OR lower(events.title) like ‘%forró%’
UNION
SELECT events.id, events.title, interests.name as Interest
FROM interests
INNER JOIN event_interests on interests.id=event_interests.interest_id
INNER JOIN events on events.id = event_interests.interest_id
WHERE lower(interests.name) like ‘%forro%’ OR lower(interests.name) like ‘%forró%’
order by interest, title
[/code]
what I want is the unique events (events.id, events.title)

Any help would be lovely, thank you