Hi,

I'm trying to dig a bit deeper into mysql queries... I've come across an
application that i'm building which requires (it would seem on the surface)
many queries, do to the relational nature of the data.

The actual app is way too complex to explain, but I've come up with a
reasonably simple example.

Let's say i've got the cliche hierarchical menu system:

parent 1
    child 1
        grandchild 1
        grandchild 2
    child 2
        grandchild 1
        grandchild 2
    child 3
    child 4
parent 2
    child 1
    child 2
    child 3
    child 4
parent 3
    child 1
    child 2
    child 3
    child 4
        grandchild 1
        grandchild 2


>From a table point of view, lets say I have 3 tables:

parent (id,name)
child (id, parentID, name)
grandchild (id, parentID, name)


Now, it's easy to query to get all the parents:

select * from parents


And it only takes 2 queries to get all the children of parent 2 (for
expanding one section of the menu)

select * from parents and
select * from children where parentID='2'


But when I decide I want to expand all the parents and children to show the
entire menu structure, it's a HEAP of queries.  Sure, I don't have to WRITE
them all, because PHP can do that for me in loops, but it occured to me that
I might be missing a HUGE piece of the puzzle in terms of what MySQL can
do...

can anyone help with a link to somewhere in the manual, or a tutorial that i
should be reading :)

thanks,

justin

mysql,query


---------------------------------------------------------------------
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