There are two queries:

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

How can I update entries in t1.price if it is null and 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.


    • 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, = CASE WHEN NULL THEN 'value' ELSE = 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.