I have a MySQL UPDATE statement that uses a CASE clause
UPDATE partsList SET quantity =
CASE
WHEN partFK = 1 THEN 4
WHEN partFK = 2 THEN 8
END
WHERE buildFK = 1;
The above statement works. Yet when I remove one of the WHEN statements, it breaks and the error indicates the CASE clause isn't returning anything. Is it that the CASE clause must have more than one WHEN to function.
I don't know beforehand how many updates I'll need, so I'm trying to build a single update statement that can handle one or many updates.
Thanks for any insights you can provide.
See Question&Answers more detail:os