www.webdeveloper.com
Results 1 to 5 of 5

Thread: Nested query within a table

  1. #1
    Join Date
    Dec 2008
    Posts
    4

    Exclamation Nested query within a table

    Hi, I have a product groups table that has a hierarchical structure that also keeps subgroup info (by parent).

    This is my table (mysql)

    Code:
    id_group  -- group_name -- parent --
    ___________________________________
         1    --  Phones    --    0   --
         2    --  Has cam   --    1   --
         3    --  No cam    --    1   --
         4    --  Has Flash --    2   --
         5    --  No Flash  --    2   --
         6    --  Many Other--    0   --
         7    --  Many Other--    0   --
         8    --  Many Other--    0   --

    Is it posible to select all product groups related to Phones with one query?
    I.e all products whose master parent is somehow "Phones" (products with id 2,3,4 and 5)

    If not posible what is the best way to do this.

    Thanks

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    is it limited to 2 levels deep? or can it go further?

  3. #3
    Join Date
    Dec 2008
    Posts
    4
    there is no level limitations but usually it does not exceed 5-6 levels

  4. #4
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634

  5. #5
    Join Date
    Dec 2008
    Posts
    4
    Perfect , this is exactly what I need.

    Thank you so much

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles