Trying to be a bit more helpful But the solution has to do with CTEs, at least if your using SQL Server as this is not standard SQL: with tmp(parent, son) as ( select tab.parent, tab.son from tab where tab.parent='A' union all select tmp.super, tab.son from tmp join tab on tmp.son=tab.parent Beware of loops! In that case you need to introduce a recursion counter or a condition that restricts son<>'A'.