I have a table (called categories) with the following fields:
cat_id, parent_id, cat_name
In this table all the main categories have as parent_id the value "0" and as cat_id another value.
The sub categories have as their parent_id the cat_id of the main category they belong to.
How can i produce a result that contains the following fields :
parent_id, cat_id, cat_name, parent_name
In the parent_name i want to show for each subcategory the name of the main category it belongs to and i want to get all the categories (main and subs).
I tried it with joining the table to itself with no success.
Some code would be helpful.
Thanks
John