I have a table with fields id,pid,name
.I want to fetch the data in the following format through a single query.
id- parent category name- name
Name would be either category or subcategory and parent category name would be none if its parent else will be parent category name.