Union vs. Intersection vs. Difference: Set Operations Explained

A plain-English guide to the four core set operations — union, intersection, difference, and symmetric difference — with worked examples.

Set operations sound academic, but they describe something you already do by hand when you scan two lists for matches. Here’s what each one means, using two small example lists:

List A: Kyoto, Lisbon, Oslo, Reykjavik, Tallinn
List B: Lisbon, Oslo, Vienna, Zagreb

Difference (A − B)

Items in A that don’t appear in B: Kyoto, Reykjavik, Tallinn. This is the one people ask for most — “what’s missing from the second list?”

Intersection (A ∩ B)

Items present in both lists: Lisbon, Oslo. Useful for finding confirmed matches — subscribers on two mailing lists, records that exist in both systems, or duplicate entries between sources.

Union (A ∪ B)

Every distinct item from either list, with duplicates removed: Kyoto, Lisbon, Oslo, Reykjavik, Tallinn, Vienna, Zagreb. This is your combined master list.

Symmetric difference (A Δ B)

Everything that appears in exactly one list, but not both: Kyoto, Reykjavik, Tallinn, Vienna, Zagreb. It’s the union minus the intersection — the complete change set between two versions of a list.

Which one do you actually need?

See all five results for your own lists.

Open the tool

Related guides