List:General Discussion« Previous MessageNext Message »
From:tbt Date:May 24 2007 5:55am
Subject:expanding hierarchies
View as plain text  
> Hi
>
> i have a table like this
>
> id      name        parent_id
> 1       europe
> 2       spain       1
> 3       england     1
> 4       france      1
> 5       london      3
> 6       mayfair     5
> 7       madrid      2
>
> in this table each destination is mapped to a parent destination
> eg: mayfair is mapped to london, london is mapped to england etc.
>
> i like to write a query to find child destinations when an id is given for
> a parent destination
> eg: if 3 is the id, then the result of query should be 3,5,6
> if 2 is the id, then the result should be 2,7
>
> the number of levels in this table is unknown and the query should work
> for any number of levels
> please provide a sample 'select' query in mysql
-- 
View this message in context:
http://www.nabble.com/expanding-hierarchies-tf3808150.html#a10777853
Sent from the MySQL - General mailing list archive at Nabble.com.

Thread
expanding hierarchiestbt24 May
  • Re: expanding hierarchiesPeter Brawley24 May
    • Re: expanding hierarchiesNaz Gassiep24 May
      • Re: expanding hierarchiesPeter Brawley24 May
        • Re: expanding hierarchiesNaz Gassiep24 May
Re: expanding hierarchiesPeter Brawley24 May