DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: recursive query

  1. #1
    Join Date
    Feb 2001
    Location
    Master Control
    Posts
    86

    recursive query

    anyone have any ideas on how to write a recursive query given the following scenario:

    given the structure:

    item1
    item1-1(parent item1)
    item1-1-1 (parent item1-1)
    item1-2(parent item1)
    item2
    item2-1(parent item2)
    item2-2-1(parent item2-1)
    etc..

    basically the numbering is irrelevant, however i want to try to get all of the items below item 1 or item 2 where the tree can go N items deep.

    as far as the db structure goes each record has the an item id and a parent item id. the top most item (item 1) will not have a parent.

  2. #2
    Join Date
    Nov 2002
    Posts
    80
    RTFM on "CONNECT BY PRIOR" syntax.

    I've had performance problems with this type of query before so try not to build your whole application around it.

  3. #3
    Join Date
    Feb 2001
    Location
    Master Control
    Posts
    86
    Thanks for the tip...dunno if the RTFM was warranted. Anyway, if anyone else is interested:

    SELECT item_id
    FROM some_table
    CONNECT BY PRIOR item_id = parent_item_id
    START WITH parent_item_id =

  4. #4
    Join Date
    Nov 2002
    Posts
    80

    Wink

    sorry about the RTFM, wasn't trying to offend

  5. #5
    Join Date
    May 2003
    Location
    San Diego
    Posts
    10
    What's RTFM?

  6. #6
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Réseaux Télématique Francophonie Multimedia

Posting Permissions

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


Click Here to Expand Forum to Full Width