How to combine two update queries having different where condition

后端 未结 2 853
名媛妹妹
名媛妹妹 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
    
    0 讨论(0)
  • 2021-02-06 20:28
    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
    
    0 讨论(0)
提交回复
热议问题