GeorgeS
Posts: 206
|
Posted: 09/19/2008, 8:53 PM |
|
Can be used for simple 2 level menu or categories structure.
Fields:
cat_id, cat_name,cat_pid
-----------------------------------------------------------------------
SELECT e.cat_id, concat_ws(' - ',IF(m.cat_name IS not NULL,'',m.cat_name),e.cat_name) AS menu_tree,
concat_ws(' > ',m.cat_name,e.cat_name) AS result
FROM menu AS e
LEFT OUTER JOIN menu AS m
ON e.cat_pid =m.cat_id
ORDER BY result, m.cat_name;
-------------------------------------------------------------------------
will create a listbox:
ABOUT US
- Our goals
- Who we are
SERVICES
- Folding
- Mailing
- Printing
_________________
GeorgeS |
|
|
|