mySQL – Anvil of Time https://anvil-of-time.com Nature Forges Everything on the Anvil of Time Thu, 11 Mar 2021 00:21:00 +0000 en-US hourly 1 Update Columns in Database https://anvil-of-time.com/ms-sql-server/update-columns-in-database/ Sat, 29 Jan 2011 01:20:36 +0000 http://anvil-of-time.com/wordpress/?p=700 It’s pretty common to want to update a column (or several columns) in one table with the value(s) from another table. Here is how to do it:

UPDATE
    Table
SET
    Table.col1 = other_table.col1,
    Table.col2 = other_table.col2
FROM
    Table
INNER JOIN
    other_table
ON
    Table.id = other_table.id 
WHERE ...

The structure of this syntax is always something I get mixed up when I want to do this.

]]>