Query

  • Dear all,

    I have following table

    emp_id emp_name parent_id

    1 aaa 0

    2 aa 1

    3 aaaa 2

    4 aaaaa 3

    5 bbb 0

    6 bbbbb 5

    7 bbbb 6

    8 bb 7

    9 aa 0

    10 aaaa 9

    11 aaaaa 10

    12 aaaaaa 11

    13 bb 0

    14 bbbb 13

    15 bbbbb 14

    16 bbbbbb 15

    17 cccc 0

    18 ccc 17

    19 cc 18

    20 ccccc 19

    21 cccccc 20

    Can anyone here pls help me(query) to create the following ?

    5 bbb 0

    6 bbbbb 5

    7 bbbb 6

    8 bb 7

    13 bb 0

    Thanks

    Peter

  • Can you tell us the rules for why those rows are being returned and not others?

    Also you will get the best replies if you post create table statements, plus a set of inserts to set up the test data.

    Thanks

    Mike John

  • Sorry for not creating the script.

    This is what i am looking for..

    For example, if user searches bb , the user expects following op. the reason is its hierarchical

    so if its represented in a tree view, its easy for the user to understand the master child relationship.

    5 bbb 0

    6 bbbbb 5

    7 bbbb 6

    8 bb 7

    13 bb 0

    I will provide the scripts lil later

    thanks

    peter

  • Hi Peter,

    Could you help me understand why

    14 bbbb 13

    15 bbbbb 14

    16 bbbbbb 15

    are not in the result set and why the result set stopped at

    13 bb 0

  • i am searching just bb

    emp_id 8 and 13 has the value bb

    the parentid of bb(8) is 7

    and parentid of bbbb (7) is 6

    and parentid of bbbbb(6) is 5

    and parentid of bbb(5) 0

    so in short i want to display parent id at the top like below

    bbb(user clicks child is displayed)

    -- bbbbb(user clicks child is displayed)

    ------bbbb(user clicks child is displayed)

    --------bb(user clicks child is displayed)

    bb(no child is displayed)

    thanks

    peter

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply