Try this:

 Update MasterTbl Set
    TotalX = Sum(D.X),    
    TotalY = Sum(D.Y),    
    TotalZ = Sum(D.Z)
 From MasterTbl M Join DetailTbl D
    On D.MasterID = M.MasterID
 

Depending on which database you are using, if that doesn't work, then try this (this is non-standard SQL but legal in SQL Server):

 Update M Set
    TotalX = Sum(D.X),    
    TotalY = Sum(D.Y),    
    TotalZ = Sum(D.Z)
 From MasterTbl M Join DetailTbl D
     On D.MasterID = M.MasterID

As mentioned in comments, if your database software does not allow the use of From clauses in Updates, then you must use the subquery approach mentioned in several other answers

Answer from Charles Bretana on Stack Overflow
🌐
W3Schools
w3schools.com › sql › sql_update.asp
SQL UPDATE Statement
The following SQL updates the record with CustomerID = 1, with a new contact person AND a new city. UPDATE Customers SET ContactName = 'Alfred Schmidt', City= 'Frankfurt' WHERE CustomerID = 1;
Discussions

Setting multiple values to a variable - Databases & Queries - Spiceworks Community
Hey Spiceheads - Is it possible to use an IN operator or select statement when setting a variable? I need to add multiple ID’s on line 5 where I am setting the @PT variable. IF OBJECT_ID('tempdb..#tmp') IS NOT NULL DROP TABLE #tmp Declare @PT int set @PT=401 --Need to add multiple ID's here ... More on community.spiceworks.com
🌐 community.spiceworks.com
3
August 1, 2014
t sql - Assigning values to multiple @variables using SELECT - Database Administrators Stack Exchange
I've encountered some T-SQL code which seems to rely on behaviour I found unexpected. When assigning values to multiple @variables in one SELECT statement, when one @variable is dependent on another, the order in which the @variables appear in the statement changes the outcome. ... DECLARE @a INT; DECLARE @b INT; SET ... More on dba.stackexchange.com
🌐 dba.stackexchange.com
November 29, 2022
How To update multiple rows at the same time in SQL
Probably not the best idea unless they are both going up by the same amount or the same percentage. There has to be something in common. More on reddit.com
🌐 r/SQL
22
7
June 13, 2021
How do I update a column with multiple different values?
both your statements update the whole table. use the 'WHERE' clause to do updates to only the rows that you need to update More on reddit.com
🌐 r/SQL
7
1
March 17, 2023
🌐
Quora
quora.com › How-do-you-update-multiple-values-in-SQL
How to update multiple values in SQL - Quora
Below are concise patterns and best practices for each case, with examples in ANSI SQL and common RDBMS variants. ... Use a single UPDATE with multiple column assignments. Syntax: UPDATE table SET col1 = expr1, col2 = expr2, col3 = expr3 WHERE condition; Example: UPDATE employees SET salary = sala ... Updating multiple values in SQL can mean different things depending on context: updating multiple columns in a single row, updating multiple rows with different values, or performing set-based updates that derive new values from other tables.
🌐
Spiceworks
community.spiceworks.com › programming & development › databases & queries
Setting multiple values to a variable - Databases & Queries - Spiceworks Community
August 1, 2014 - Hey Spiceheads - Is it possible to use an IN operator or select statement when setting a variable? I need to add multiple ID’s on line 5 where I am setting the @PT variable. IF OBJECT_ID('tempdb..#tmp') IS NOT NULL DROP TABLE #tmp Declare @PT int set @PT=401 --Need to add multiple ID's here Declare @DN int set @DN=2121 Select distinct p.perf_no INTO #tmp From T_PERF AS p join TX_PERF_PMAP pp on p.perf_no=pp.perf_no WHERE p.prod_season_no = 8079 and pp.price_type=@PT DECLARE @X int Se...
🌐
DbSchema
dbschema.com › blog › tutorials › sql update statement – syntax, examples, and best practices | dbschema
SQL UPDATE Statement – Syntax, Examples, and Best Practices | DbSchema
August 23, 2025 - The UPDATE statement is used to modify existing records in a table by changing the values of one or more columns. The basic syntax for the UPDATE statement is as follows: UPDATE table_name SET column1 = value1, column2 = value2, ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › sql › how-to-update-multiple-records-using-one-query-in-sql-server
How to Update Multiple Records Using One Query in SQL Server? - GeeksforGeeks
To update multiple records of a ... syntax: UPDATE table_name SET column_value = CASE column_name WHEN 'column_name1' THEN column_value1 WHEN 'column_name2' THEN column_value2 ELSE column_value END WHERE column_name IN('column_name1', 'column_name2');...
Published   July 23, 2025
🌐
GeeksforGeeks
geeksforgeeks.org › sql › how-to-update-multiple-columns-in-single-update-statement-in-sql
How to Update Multiple Columns in Single Update Statement in SQL? - GeeksforGeeks
We can update multiple columns at once by specifying them after the SET keyword, and we can update data based on conditions using the WHERE clause. Additionally, we can update values across multiple tables by using JOINs.
Published   July 23, 2025
🌐
DataCamp
datacamp.com › tutorial › update-multiple-columns-sql
How to Update Multiple Columns in SQL | DataCamp
November 8, 2024 - -- Update multiple columns UPDATE employees -- Increase the salary by $5000 for each SET salary = salary + 5000, position = 'Senior Sales Associate' WHERE department = 'Sales' AND years_of_experience > 5; Gain practical knowledge in ETL, SQL, and data warehousing for data engineering. ... In some cases, updating multiple columns in SQL requires more advanced techniques, especially when handling null values, conditional logic, or updating based on data from other tables.
🌐
Reddit
reddit.com › r/sql › how do i update a column with multiple different values?
r/SQL on Reddit: How do I update a column with multiple different values?
March 17, 2023 -

Hi there,

I'm trying to run through a table updating a column depending on certain variables. When I run the first update all is fine, but the second update goes over the first and makes them null. I hope that makes sense. example code below, any help is appreciated.

UPDATE table

set column = CASE WHEN ( x= x and y= y) THEN 1a WHEN (x=y and y=x) then 1b END

UPDATE table

set column = CASE WHEN (Z= Z and v=v) then 2 END

🌐
SQLServerCentral
sqlservercentral.com › forums › topic › updating-multiple-values-from-1-table-to-another
Updating multiple values from 1 table to another – SQLServerCentral Forums
May 8, 2012 - Select @sql = 'Update Ex2 Set ColumnValue = '+@value+' Where ColumnName = '''+@colname+''';' Execute (@sql) End · Else · Begin · Return · End · End · --Test Execution Of trigger · Insert Into Ex · Select 'Phone', '2222222' Select * From Ex · Select * From Ex2 · That trigger will not work when there are multiple rows in a single insert.
🌐
Medium
medium.com › geekculture › update-multiple-rows-in-sql-with-different-values-at-once-7d2eddb0b85f
Update multiple rows in SQL with different values at once | by Tadej Golobic | Geek Culture | Medium
June 12, 2021 - But can we do this faster? Well, first, I started googling a little bit and i found this SQL solution: UPDATE users SET firstName = (case when id = 1 then 'encryptedFirstName1' when id = 2 then 'encryptedFirstName2' when id = 3 then 'encryptedFirstName3' end) WHERE id in (1, 2, 3);
🌐
W3Schools
w3schools.com › sql › sql_in.asp
SQL IN Operator
The following SQL uses multiple OR conditions to select all customers from Germany, France, or UK (same result, but longer code): SELECT * FROM Customers WHERE Country = 'Germany' OR Country = 'France' OR Country = 'UK'; SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2, ...);
🌐
Scaler
scaler.com › home › topics › update multiple columns in sql
Update Multiple Columns in SQL - Scaler Topics
May 4, 2023 - We can update multiple columns in SQL using the UPDATE command. The UPDATE statement is followed by a SET statement, which specifies the column(s) where the update is required. ... At first, we use the UPDATE command with the name of the table ...
🌐
YouTube
youtube.com › watch
UPDATE multiple values in SQL
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
🌐
SQL Easy
sql-easy.com › learn › how-to-update-multiple-columns-in-sql
How to Update Multiple Columns in SQL: Efficient Techniques and Tips - SQL Knowledge Center
June 28, 2023 - UPDATE table_name SET column1 = value1, column2 = value2, ... columnN = valueN WHERE condition; Notice that the column-value pairs are separated by commas, ensuring that the database system understands which values correspond to which columns.
🌐
MSSQLTips
mssqltips.com › home › when to use set vs select for assigning sql server variables
When to use SET vs SELECT for assigning SQL Server Variables
November 25, 2009 - Whenever you are assigning a query returned value to a variable, SET will accept and assign a scalar (single) value from a query. While SELECT could accept multiple returned values. But after accepting multiple values through a SELECT command you have no way to track which value is present in the variable.
🌐
ProjectPro
projectpro.io › recipes › enter-single-and-multiple-values-table-sql
SQL Values - How to Enter Single and Multiple Values in a Table in SQL? -
January 11, 2024 - SET column1 = value1, column2 = value2, ... ... This updates the salary for employees with the last name 'Doe' to 55000. This recipe has covered the basics of entering single and multiple values into a table in SQL.