how to retrieve record from one to many relationship table

  • hi

    I have two table like as shown below

    TABLE1 TABLE2

    ID VALUE ID1 ID2 REGISTERNO

    1 a 1 2 999

    2 B 2 1 800

    3 C 3 1 750

    4 D 4 3 988

    Note: the table2 ID1,ID2 can be any value which is present in the table1.ID

    i need the output as:

    REsult1:(Value for the corresponding ID1)

    REsult2:(Value for the corresponding ID2)

    ---------------------------

    Registerno result1 result2

    ----------------------------

    999 a B

    800 B a

    750 C a

    988 D C

  • patr (11/5/2008)


    hi

    I have two table like as shown below

    TABLE1 TABLE2

    ID VALUE ID1 ID2 REGISTERNO

    1 a 1 2 999

    2 B 2 1 800

    3 C 3 1 750

    4 D 4 3 988

    Note: the table2 ID1,ID2 can be any value which is present in the table1.ID

    i need the output as:

    REsult1:(Value for the corresponding ID1)

    REsult2:(Value for the corresponding ID2)

    ---------------------------

    Registerno result1 result2

    ----------------------------

    999 a B

    800 B a

    750 C a

    988 D C

    USe this

    select a.Registorno, b.value, c.Value From dummy1 as a

    inner join dummy as b on a.ID1 = b.ID

    inner join dummy as c on a.ID2 = c.ID

    kshitij kumar
    kshitij@krayknot.com
    www.krayknot.com

  • Thank u Kray ....

    Hats off for uu!!!

    the query works well.

    😛

  • patr (11/6/2008)


    Thank u Kray ....

    Hats off for uu!!!

    the query works well.

    😛

    My pleasure

    kshitij kumar
    kshitij@krayknot.com
    www.krayknot.com

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

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