http://www.amazon.com/exec/obidos/ASIN/1558605762/qid=1023135114/sr=8-1/ref=
sr_8_1/104-1283502-0494342

SQL for Smarties by the demigod Joe Celko.  Chapters 28 and 29 describe this
tree structure.  READ BOTH OF THEM, even though you won't use the code in
28. Chap 29 holds the simplified concepts to make a tree structure work with
single select.

It's not easy. It's a complex concept but once you master it you'll find
100's of uses for it. (I use it to open pickle jars these days!)  :)

=C=

*
* Cal Evans
* Journeyman Programmer
* Techno-Mage
* http://www.calevans.com
*


-----Original Message-----
From: Chris Boget [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 03, 2002 3:04 PM
To: [EMAIL PROTECTED]
Subject: Record dependancies


Is there a way to do this in one query (never mind the possibilities
for endless loops):

Say you have a table that looks like this:

fieldName       dependantOn

"joe"               "monster"
"bob"              "joe"
"briggs"
"monster"       "briggs"
"vision"

I want to do a query so that the records are ordered as follows
(based on the value of the 'dependantOn' field)

briggs
monster
joe
bob
vision

How can I do this in one query?  I obviously cannot ORDER BY
dependantOn because in the end, the dependancies wouldn't be
resolved.  ORDER BY fieldName is moot as it doesn't address
the need.

Anyone have any ideas, suggestions?  Is this even possible?  Or
am I barking up the wrong tree and I'm going to have to figure this
out via multiple queries?

Chris




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to