There are two queries:

UPDATE stationery_request t1 SET t1.price=4 WHERE t1.price is null UPDATE stationery_request t1 SET t1.name='value' WHERE t1.name is null 

How can I update entries in t1.price if it is null and t1.name if they are not null independently of each other, in one request?

    2 answers 2

     UPDATE stationery_request SET price = COALESCE(price,4), name = COALESCE(name, 'value') WHERE price is null OR name is null 

    I use WHERE in order to somehow reduce the sample.

    COALESCE

    • This option is more like it. - IVsevolod

    You can use this approach:

     UPDATE stationery_request t1 SET t1.price = CASE t1.price WHEN NULL THEN 4 ELSE t1.price = t1.price END, t1.name = CASE t1.name WHEN NULL THEN 'value' ELSE t1.name = t1.name END 

    It is better not to combine. But now ask yourself the question, is it necessary? Than you are not satisfied with individual requests?

    Individual requests will be even faster than such parsley, if properly arrange the indices.