Upsert

INSERT INTO demo_table
(uid,type,thingid,lasttime)
VALUES
(1,0,3,4.5),(2,0,3,4)
ON DUPLICATE KEY UPDATE
type = CASE uid
WHEN 1 THEN 0
WHEN 2 THEN 0
END,
thingid = CASE uid
WHEN 1 THEN 4
WHEN 2 THEN 3
END,
lasttime = CASE uid
WHEN 1 THEN 4.5
WHEN 2 THEN 4
END

Update

UPDATE demo_table
SET thingid=CASE uid
WHEN 1 THEN 1
WHEN 2 THEN 2
END
WHERE
uid IN (1,2)

以上内容来自小天的博客