I have a table where i store categories with its parent’s id. Following is the table structure
What i need is to get the parent and details of id 4 in a single query without php recursion
id | CategoryName | parentid
1 Web 0
2 Software 0
3 PHP 1
4 Arrays 3
A self join should be sufficient here. Your goal is to join the table against itself, while relating the
parentidof the main row to theidof its parent’s row.