About 21,700,000 results
Open links in new tab
  1. sql - Update multiple values in a single statement - Stack Overflow

    Nov 14, 2008 · update MasterTbl set TotalX = sum(DetailTbl.X), TotalY = sum(DetailTbl.Y), TotalZ = sum(DetailTbl.Z) from DetailTbl where DetailTbl.MasterID = MasterTbl.ID group by MasterID but that doesn't work. I've also tried versions that omit the "group by" clause.

  2. SQL - Update multiple records in one query - Stack Overflow

    Try either multi-table update syntax. ON t1.config_name = 'name1' AND t2.config_name = 'name2' SET t1.config_value = 'value', t2.config_value = 'value2'; Here is a SQLFiddle demo. or conditional update. SET config_value = CASE config_name . WHEN 'name1' THEN 'value' . WHEN 'name2' THEN 'value2' . ELSE config_value. END.

  3. SQL Statement with multiple SETs and WHEREs - Stack Overflow

    Best option is multiple updates. Alternatively you can do the following but is NOT recommended: WHEN ID = 2724 THEN 111111261. WHEN ID = 2021 THEN 111111263. WHEN ID = 2017 THEN 111111264. END. nice one + 1. Sometimes it is not the best script that gets rewarded.

  4. SQL UPDATE Statement - W3Schools

    The UPDATE statement is used to modify the existing records in a table. SET column1 = value1, column2 = value2, ... Note: Be careful when updating records in a table! Notice the . WHERE clause in the UPDATE statement. The WHERE clause specifies which record (s) …

  5. How to Update Multiple Records Using One Query in SQL Server?

    May 13, 2024 · To update multiple records of a table based on a single condition in an SQL server, use this syntax: As you can see, we can update multiple values of a column in SQL server using an UPDATE statement with a WHERE clause. Sometimes, we need to update values of a column based on multiple conditions.

  6. Update Multiple Rows With Different Values With Single Query

    21 hours ago · An intuitive way we might approach this problem is by using multiple UPDATE queries: UPDATE users SET user_type = 'ADULT' WHERE age >= 18; UPDATE users SET user_type = 'JUNIOR' WHERE age < 18; These queries use the WHERE clause to determine when to UPDATE a record and set the user_type column to …

  7. How to Update Multiple Columns in Single Update Statement in SQL?

    Dec 17, 2024 · Rather than executing separate update statements for each column, SQL provides a way to update multiple columns at once in a single query. In this article, we will explain the syntax and examples of updating multiple columns in a single UPDATE statement.

  8. mysql - How can I UPDATE multiple ROWs in a Single Query with multiple

    Feb 18, 2018 · UPDATE is different than SELECT. A "cross join" is usually really bad for performance. Etc. A, B. A.col1 = 'abc', A.col2 = 'xyz', B.col1 = CASE B.col3. WHEN '1' THEN 'a' WHEN '2' THEN 'b' WHEN '3' THEN 'c' END, B.col2 = CASE B.col3. WHEN '1' THEN 'x' WHEN '2' THEN 'y' WHEN '3' THEN 'z' END. A.col3 = '1' AND B.col3 IN ('1', '2', '3')

  9. Efficiently Updating Multiple Rows with SQL - codersjungle.com

    Oct 9, 2024 · One effective strategy for batch updates is to leverage the CASE statement within the UPDATE command. This approach allows you to specify different new values for different records in a single statement, saving time and resources. For example, if we want to update the salaries of several employees based on their department, we can do it as follows:

  10. How to Update Multiple Records in SQL Based on a Condition

    Mar 8, 2025 · Learn how to update multiple records in a table in SQL using the UPDATE statement with a condition, such as increasing salaries for employees over 30.

  11. Some results have been removed
Refresh