RE: HELP RE. SQL UPDATE table1 with info from table2
Posted in 1995
Viggo, I'm a bit fuzzy on your example, but I think you are looking for this: UPDATE table1 SET (field1, field3) = ((SELECT field1, field3 FROM table2 WHERE key = table1.key)) WHERE key = <anything you might want to add to narrow the update>; --Craig (craig@chemistry.utah.edu) }I want to update table1 with values from table2. } }Table1 (100000 records) }---------- }key unique }field1 }field2 }field3 } }Table2 (5000 records, all keys is known in table1) }---------- }key unique }field1 }field3 } }I could easily extract 5000 update statements to a file, on basis of }the records in table2. } }ex: update table1 (field1, field3) set (field1, field3) = } (select field1, field3 from table2 where key = unique_value) } where key = same_unique_value } update ...... unique_value2 .... }etc etc (5000 statements in all) } }but I don't like that solution. }