multiple self-join
I have a table with this structure and content
IdA Name FK_Ida
1 A 1
2 Aa 1
3 Ab 1
4 Aaa 2
5 Abb 2
6 Acc 3
7 Add 3
I want to use a SQL-query to get this result
A Aa Aaa
A Aa Abb
A Ab Acc
A Ab Add
I've tryed this:
SELECT a.Name as ParentCategory, b.Name
FROM table as a right JOIN table AS b
ON a.ida = b.fk_ida
Select a.Name as ParentCategory, b.Name
From table a, table b
Where a.ida = b.fk_ida
But both of them give me just the "top level" and "sub level" but not the "sub sub level"
Can someone help me with a correct SQL-question to get all of the levels in a table like that?
Thank you
//Matte
|