要實現批量更新SQL,可以使用以下方法:
UPDATE your_table
SET column1 =
CASE
WHEN condition1 THEN value1
WHEN condition2 THEN value2
ELSE column1
END,
column2 =
CASE
WHEN condition1 THEN value3
WHEN condition2 THEN value4
ELSE column2
END
WHERE your_condition;
UPDATE your_table
SET column1 = subquery.column1,
column2 = subquery.column2
FROM (
SELECT id, new_value1 AS column1, new_value2 AS column2
FROM your_table
WHERE your_condition
) AS subquery
WHERE your_table.id = subquery.id;
UPDATE your_table
SET column1 = another_table.new_value1,
column2 = another_table.new_value2
FROM your_table
JOIN another_table ON your_table.id = another_table.id
WHERE your_condition;
以上是幾種常用的實現批量更新SQL的方法,具體應用取決于數據的結構和更新的邏輯。