From: Peter Brawley Date: August 2 2006 9:53pm Subject: Re: logic/db question List-Archive: http://lists.mysql.com/mysql/200540 Message-Id: <44D11EE1.7030209@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=======AVGMAIL-44D11EE256DA=======" --=======AVGMAIL-44D11EE256DA======= Content-Type: multipart/alternative; boundary=------------020806080908070504040602 --------------020806080908070504040602 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Bruce >tried to get to the link...saw that it's 'localhost'!!!!!! Sorry! http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html PB ----- bruce wrote: > hi peter... > > tried to get to the link...saw that it's 'localhost'!!!!!! > > what's the real/actual url... > > -bruce > > > -----Original Message----- > From: Peter Brawley [mailto:peter.brawley@stripped] > Sent: Wednesday, August 02, 2006 2:15 PM > To: bedouglas@stripped > Cc: mysql@stripped > Subject: Re: logic/db question > > > Bruce, > > >> my question, how can i come up with a sql query that will list all the >> children (and children's children...) of a top level item? >> > > This is an edge list tree model, ID being the child node, parentID being > the parent node, the row denoting the edge between ID and parentID. > Unless you know in advance how many levels there are, you need an sproc > to retrieve subtrees.There is an example with discussion in Listing 7 at > http://localhost/artful/mysqlbook/sampler/mysqled1ch20.html. > > PB > > ----- > > bruce wrote: > >> hi... >> >> i have a tbl >> fooTBL >> name >> parentID >> ID >> >> so a name can have might have a parentID, as well as an ID. 'name's are >> associated with other 'name's via the parentID. in other words, if a >> > name's > >> parentID == a name's ID, name1 is the parent of name2. >> >> ie >> >> name parentID ID >> stanford '' 1 >> fall-06 1 2 >> spring-06 1 3 >> summer-06 1 4 >> acct 2 5 >> biol 2 6 >> math 2 7 >> acct 3 8 >> biol 3 9 >> math 3 10 >> acct 4 11 >> biol 4 12 >> math 4 13 >> stanford '' 14 >> fall-06 14 15 >> spring-06 14 16 >> summer-06 14 17 >> acct 15 18 >> biol 15 19 >> math 15 20 >> etc.... >> >> my question, how can i come up with a sql query that will list all the >> children (and children's children...) of a top level item? >> >> searching google gives some insight into how to handle recursion/tree >> issues. i haven't as of yet come across anything that gets me to where i >> need to be. can this be handled with only a single table? >> >> i also need the select/delete/insert queries to be reasonably fast.. >> >> i had done this awhile ago.. but can't recall how i did it.. >> >> thanks >> >> -bruce >> >> >> >> > > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.1.394 / Virus Database: 268.10.5/404 - Release Date: 7/31/2006 > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/mysql?unsub=bedouglas@stripped > > > > --------------020806080908070504040602 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
>tried to get to the link...saw that it's 'localhost'!!!!!!Sorry! http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html
--------------020806080908070504040602-- --=======AVGMAIL-44D11EE256DA======= Content-Type: text/plain; x-avg=cert; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Description: "AVG certification" No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.10.5/404 - Release Date: 7/31/2006 --=======AVGMAIL-44D11EE256DA=======--hi peter... tried to get to the link...saw that it's 'localhost'!!!!!! what's the real/actual url... -bruce -----Original Message----- From: Peter Brawley [mailto:peter.brawley@stripped] Sent: Wednesday, August 02, 2006 2:15 PM To: bedouglas@stripped Cc: mysql@stripped Subject: Re: logic/db question Bruce,my question, how can i come up with a sql query that will list all the children (and children's children...) of a top level item?This is an edge list tree model, ID being the child node, parentID being the parent node, the row denoting the edge between ID and parentID. Unless you know in advance how many levels there are, you need an sproc to retrieve subtrees.There is an example with discussion in Listing 7 at http://localhost/artful/mysqlbook/sampler/mysqled1ch20.html. PB ----- bruce wrote:hi... i have a tbl fooTBL name parentID ID so a name can have might have a parentID, as well as an ID. 'name's are associated with other 'name's via the parentID. in other words, if aname'sparentID == a name's ID, name1 is the parent of name2. ie name parentID ID stanford '' 1 fall-06 1 2 spring-06 1 3 summer-06 1 4 acct 2 5 biol 2 6 math 2 7 acct 3 8 biol 3 9 math 3 10 acct 4 11 biol 4 12 math 4 13 stanford '' 14 fall-06 14 15 spring-06 14 16 summer-06 14 17 acct 15 18 biol 15 19 math 15 20 etc.... my question, how can i come up with a sql query that will list all the children (and children's children...) of a top level item? searching google gives some insight into how to handle recursion/tree issues. i haven't as of yet come across anything that gets me to where i need to be. can this be handled with only a single table? i also need the select/delete/insert queries to be reasonably fast.. i had done this awhile ago.. but can't recall how i did it.. thanks -bruce-- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.10.5/404 - Release Date: 7/31/2006 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=bedouglas@stripped