sql select parent and child records code example
Example: how to get parent and child record in single query using sql
SELECT child.Id,
child.Name,
child.ParentId,
parent.Name as ParentName
FROM your_table child
JOIN your_table parent ON child.ParentId = parent.id;