'what is blanket update in SQL query?

I have a few update queries, and I need them as a blanket update.

update Table_A  set status=0 where task_type='AAA' and task_name='BBB';

update Table_A set status=0 where task_type='CCC' and task_name='DDD';

update Table_A  set status=0 where task_type='EEE' and task_name='FFF';

I need this to be a blanket update

sql


Solution 1:[1]

It sounds like you need a single update that will cover all your scenarios - something like this

update Table_A  set status= 
    case 
        when task_type ='AAA' and task_name='BBB' then 0
        when  task_type='CCC' and task_name='DDD' then 0
        when task_type='EEE' and task_name='FFF' then 0
    end;

This works in MySQL, MSSQL, SQLite and PostgreSQL. I haven't tested it in Oracle

If you have other conditions then just extend the Case statement

Solution 2:[2]

You can just combined all three where clauses with or

update Table_A  set status=0 
where (task_type='AAA' and task_name='BBB')
or (task_type='CCC' and task_name='DDD')
or (task_type='EEE' and task_name='FFF');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CHill60
Solution 2 Kazi Mohammad Ali Nur