Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2004
    Posts
    3

    Unanswered: Update child records help

    Please help

    I have table1 which has many unique ID numbers and table2 that has many records for each ID. some of the ID numbers in table1 have changed and I have created a translation table (table3) that links the old and new ID numbers.

    What I need to do is some sort of update sql statement that updates all the records in table2 changing all the oldID numbers to the new ones using the translation table.

    Table1 and table2 are not linked...can anyone help me with the sql statement

    example

    Table 1
    IDNUM NAME
    12345 Joe
    12346 Mary
    12347 David

    Table2
    IDNUM FIELD1
    12345 hello
    12345 goodbye
    12346 hello
    12347 goodbye
    12346 hello
    12346 goodbye

    Table3
    OLDID NEW ID
    12345 54321
    12347 74321

    need to change the IDNUM in Table2 to 54321 where IDNUM = 12345 and same with 12347..Need to do this for many many IDs but not all.

    Thanks very much

  2. #2
    Join Date
    Feb 2004
    Posts
    492
    Something like this?

    update tab2
    set myint = myotherint
    from tab3 t3
    where tab2.myint = t3.myint

Posting Permissions

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