Imagine that I have a table like the below table in my database, how can I write a query that returns all of the places that are a part of the place that I use as input for this query?
For example, if I send:
(this is the input) (I want this result)
1 (Europe) France, Italy, Paris, PartA, PartAA
3 (France) Paris, PartA, PartAA
4 (Paris) PartA, PartAA

As suggested by Martin Smith I had a look at recursive CTEs and this is what I came up with:
It’s completely untested, though.