I have a table like this:
[Mappings]
Parent | Child
---------------
4 | 10
1 | 4
In SQL, I'm trying to run a query with an input of 10
, and get back all of its parents up the chain... so 4
and 1
in this case.
If I run this with an input of 4
, it would return 1
.
I'm thinking I need to use a common table expression (CTE), but the syntax is throwing me off.