UPDATE -- ignore records not in CASE expression
08:56 14 Nov 2019

How do you ignore records not inside the case expression when using CASE/WHEN/THEN?

For example, this statement will update three matching records as expected but will make all student records that do not match a WHEN/THEN clause to NULL

UPDATE table SET student = (CASE WHEN student = '10' THEN '100412'
                                 WHEN student = '17' THEN '100295' 
                                 WHEN student = '26' THEN '100981'
                            END)
WHERE year = '2019';

How can you skip over records not inside the CASE expression and only change records that have a matching clause?

mysql sql mariadb