So, I'm messing around with nested sets for dealing with tree data. But,
I've come across a snag. It would appear that you can't alphabetize the
children at the same level, at least I haven't figured out how to do it.

Does anyone have a solution for that?

Note: I'm using a modified version of the cfc code from a CFDJ article on
the topic. Table structure like so:
categoryid    category                lft            rgt
1                    parent 1                1            6
2                    child of parent 1    2            3
3                    A second child        4            5

To return all nodes, you run a query like so:
SELECT child.category, COUNT(child.lft) AS lvl, child.lft, child.rgt,
child.categoryid
FROM category  parent, category  child
WHERE child.lft BETWEEN parent.lft AND parent.rgt
GROUP BY child.lft, child.rgt, child.category, child.categoryid
ORDER BY child.lft

This results in
Parent 1
--child of parent 1
--a second child

When what I'd like is:
Parent 1
--a second child
--child of parent 1

Thoughts? Elegant solutions?

--
Deanna Schneider
UWEX-Cooperative Extension
Interactive Media Developer
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to