I have a table called CATEGORIES.
Cat_ID
Cat_Parent_ID
Cat_Desc
Cat_Level
Most of the categories in the table are nested 2 deep. However there are 4 of them that are nested 3 deep.
I need to pull out the data so I can nest it like so (using Cold Fusion on the server-side):
category
products
sub_category
products
fine_category
products
I am currently using this SQL statement, but it is not returning the full hierarchy that I need.
SELECT b.cat_desc as category, c.cat_desc as sub_category ,d.cat_desc as fine_category, d.cat_id
FROM Categories d LEFT OUTER JOIN Categories c ON d.CAT_PARENT_ID = c.CAT_ID
LEFT OUTER JOIN Categories b ON c.CAT_PARENT_ID = b.CAT_ID
ORDER by category, sub_category, fine_category
Help!!
Cat_ID
Cat_Parent_ID
Cat_Desc
Cat_Level
Most of the categories in the table are nested 2 deep. However there are 4 of them that are nested 3 deep.
I need to pull out the data so I can nest it like so (using Cold Fusion on the server-side):
category
products
sub_category
products
fine_category
products
I am currently using this SQL statement, but it is not returning the full hierarchy that I need.
SELECT b.cat_desc as category, c.cat_desc as sub_category ,d.cat_desc as fine_category, d.cat_id
FROM Categories d LEFT OUTER JOIN Categories c ON d.CAT_PARENT_ID = c.CAT_ID
LEFT OUTER JOIN Categories b ON c.CAT_PARENT_ID = b.CAT_ID
ORDER by category, sub_category, fine_category
Help!!