Hi all,
I am populating data from a table which contain parent id which reference to itself
E.g.: TableA - ID, Name, Desc, ParentID
ParentID reference to ID
I would need the result to return:
ID, Name, Desc, ParentID, ParentName, ParentDesc
Select statement:
SELECT ID, Name, Desc, ParentID,
(SELECT Name from TableA WHERE ID=ParentID) AS ParentName,
(SELECT Desc from TableA WHERE ID=ParentID) AS ParentDesc
FROM TableA;
Is there any performance issue using this approach?
Is there a better way of doing this?