nix, shell, perl, php, mysql and mac os x tips and tricks

Friday, October 24, 2003

MySQL to show an entire category tree

SELECT a.category_name AS parent_name,
b.category_name AS child_name, 
a.category_code as a_category_code, 
a.category_parent AS a_category_parent, 
b.category_code as b_category_code, 
b.category_parent AS b_category_parent
FROM categories_raw_loop AS a, categories_raw_loop AS b 
WHERE a.category_code = b.category_parent
ORDER BY a.category_code;

No comments:

Post a Comment