Search results
23 cze 2013 · I am trying to UPDATE values from a table, but I need to add some conditions. I found the function CASE, but I am not if it is the best method. Here is an example.
16 kwi 2016 · UPDATE Tests AS old INNER JOIN ( SELECT 10 AS TestId, 25 AS TestSubId, 1000 AS TestScore, 2000 AS TestScore2 UNION ALL SELECT 11, 22, 1100, 2100 ) AS new ON old.TestId = new.TestId AND old.TestSubId = new.TestSubId SET old.TestScore = new.TestScore, old.TestScore2 = new.TestScore2 ;
29 gru 2017 · You will need to write very complicated conditions if you want to update more than two rows. In such a case you can use INSERT ... ON DUPLICATE KEY UPDATE approach.
20 gru 2023 · Using case would be an option : UPDATE some_table. SET mark_col_1_as_exported = CASE WHEN exp_col_1 = 1 THEN 0 ELSE mark_col_1_as_exported END , mark_col_2_as_exported = CASE WHEN exp_col_2 = 2 THEN 0 ELSE mark_col_2_as_exported END. WHERE exp_col_1=1 OR exp_col_2=2;
16 lut 2024 · In this article, we’ll learn the use of the CASE statement, IF() function, INSERT ... ON DUPLICATE KEY UPDATE clause and UPDATE with JOIN() function to update multiple columns in multiple rows with different values in MySQL.
26 cze 2024 · Updating table rows using subqueries in MySQL enables precise modifications based on specific conditions or values from other tables. This technique leverages subqueries within the SET or WHERE clauses of the UPDATE statement, allowing dynamic and context-specific updates.
11 cze 2024 · Updating table rows using subqueries in MySQL enables precise modifications based on specific conditions or values from other tables. This technique leverages subqueries within the SET or WHERE clauses of the UPDATE statement, allowing dynamic and context-specific updates.