Hi All,
I have a table (this cannot be changed) like the following:
POST_ID | PARENT_ID | POST_NAME
1 | 0 | Services
4 | 1 | Development
5 | 4 | Magento
2 | 0 | Contact
The field, 'parent_id' references post_id to form a self-referential foreign key. Is it possible to write a single query to connect a post and it's parents based on the post_id?
For example, if I had the post_id 5 (Magento), could I write a query to produce the following results:
5 | Magento
4 | Development
1 | Services
I know this is quite easy to do with multiple queries, however, wish to know whether it is possible with a single query.
Thanks :)