Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    25

    Unanswered: Multi-level subdirectories

    Hi,
    I have a table with 2 columns: "dir" and "subdir".

    This is a sample data:
    DIR SUBDIR
    151 228
    151 235
    151 236
    151 238
    228 229
    228 230
    230 231
    231 232
    231 233
    231 234
    236 237

    I would like to extract all the records related to one directory, and all of its subdirectories. For example, with the directory 228, I should get as result:
    228 229
    228 230
    230 231
    231 232
    231 233
    231 234

    Because 231 is a subdirectory of 230, and 230 is a subdirectory of 228.

    Thanks in advance!

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Here it is:
    Code:
    SELECT dir, subdir
    FROM directories
    START WITH dir = 228
    CONNECT BY PRIOR subdir = dir;

  3. #3
    Join Date
    Oct 2004
    Posts
    25

    Thumbs up

    Thank you so much! I didn't know this syntax. It works perfectly!

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Be sure to remember 11th of August 2006 - that was the day you first saw me ... ooops! I meant to say "this syntax", not "me"

Posting Permissions

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