How to combine two update queries having different where condition

后端 未结 2 857
名媛妹妹
名媛妹妹 2021-02-06 19:41

How can I combine this two update statements :

update Special_quota set Status=0,Additional_msg_quota=0 where User_id not  in(\'1\',\'2\',\'3\') 

update Special         


        
2条回答
  •  难免孤独
    2021-02-06 20:26

    You can use CASE expression like this:

    UPDATE Special_quota 
    set Status = CASE WHEN User_ID IN('1','2','3') then 1 else 0 end,
        additional_msg_quota = CASE WHEN User_ID IN('1','2','3') then 30 else 0 end
    

提交回复
热议问题