update select sql

Solutions on MaxInterview for update select sql by the best coders in the world

showing results for - "update select sql"
Erica
28 Mar 2019
1UPDATE YourTable 
2SET Col1 = OtherTable.Col1, 
3    Col2 = OtherTable.Col2 
4FROM (
5    SELECT ID, Col1, Col2 
6    FROM other_table) AS OtherTable
7WHERE 
8    OtherTable.ID = YourTable.ID
Leah
10 Apr 2019
1--the simplest way of doing this 
2UPDATE
3    table_to_update,
4    table_info
5SET
6    table_to_update.col1 = table_info.col1,
7    table_to_update.col2 = table_info.col2
8
9WHERE
10    table_to_update.ID = table_info.ID