add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE products (`key` VARCHAR(255) PRIMARY KEY, cost INT);
INSERT INTO products VALUES ('a', 5), ('c', 6);
SELECT * FROM products;
Records: 2  Duplicates: 0  Warnings: 0
key cost
a 5
c 6
INSERT INTO products
SELECT updates.key, updates.cost
FROM (
VALUES
ROW ('a', 10),
ROW ('c', 3),
ROW ('foo', 8)
) AS updates (`key`, cost)
ON DUPLICATE KEY
UPDATE products.cost = products.cost + updates.cost;
SELECT * FROM products;
Records: 3  Duplicates: 2  Warnings: 0
key cost
a 15
c 9
foo 8