identity table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kollurisaritha
    New Member
    • Mar 2008
    • 1

    identity table

    Hi

    I have 2 tables like

    Searchtable
    -----------------
    searchid name
    ----------- --------
    s1 chandu
    s2 sony
    s3 kiran
    s4 chandu
    s5 babu

    Master table(Data from search table avoiding duplicates)
    -----------------
    masterID SearchID Name
    ------------ ----------- ---------
    M1 s1 chandu
    M2 s2 sony
    M3 s3 kiran
    M4 s5 babu


    I want a table to maintain Identity like this as output

    identitytable
    -----------------
    masterID SearchID
    ------------ -------------
    M1 s1
    M2 s2
    M3 s3
    M1 s4
    M4 s5

    Can any one tell me how to write query for this solution

    Thanks in advance.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by kollurisaritha
    Hi

    I have 2 tables like

    Searchtable
    -----------------
    searchid name
    ----------- --------
    s1 chandu
    s2 sony
    s3 kiran
    s4 chandu
    s5 babu

    Master table(Data from search table avoiding duplicates)
    -----------------
    masterID SearchID Name
    ------------ ----------- ---------
    M1 s1 chandu
    M2 s2 sony
    M3 s3 kiran
    M4 s5 babu


    I want a table to maintain Identity like this as output

    identitytable
    -----------------
    masterID SearchID
    ------------ -------------
    M1 s1
    M2 s2
    M3 s3
    M1 s4
    M4 s5

    Can any one tell me how to write query for this solution

    Thanks in advance.
    Names are not really a good column to use as key, but here's your query:
    Code:
    select MasterTable.MasterID   , Searchtable.searchid
    from Searchtable
    left join MasterTable on MasterTable.name = SearchTable.Name
    -- CK

    Comment

    Working...