I would like to update a selection of rows from a column (Column1) in a table (Table1) with a value of my choosing (i.e. not a value from another table).
- The row selection is based on a condition in an unshared column (Column3) in another table (Table2).
- Table1 and another table (Table2) share a column (Column2).
- Some rows in Column1 currently contain null values.
I've created a SELECT statement that pulls up the correct rows, which is as follows:
SELECT Table1.Column1, Table2.Column2
FROM Table1
RIGHT JOIN Table2 ON Table1.Column2 = Table2.Column2
WHERE Table2.Column3 = 'Condition'
However, as I'm very new to SQL, I'm unsure how to turn this into an UPDATE statement that updates Column1 into a value of my choosing.
Would something like this work?
UPDATE Table1
SET Table1.Column1 = 'Value'
FROM Table1
RIGHT JOIN Table2 ON Table1.Column2 = Table2.Column2
WHERE Table2.Column3 = 'Condition'
Many thanks.