开发者

Multiple SET expressions in query?

Want to update specific data in a Table Column.

I can use the below for one entry:

UPDATE [BULDING].[dbo].[TB_DATA]

SET OFFICE_ID = '4' where OFFICE__ID = '8';

But what should I use for multiple entry change - below obviously does not 开发者_Go百科work:

UPDATE [BULDING].[dbo].[TB_DATA]

SET OFFICE_ID = '4' where OFFICE_ID = '8'

SET OFFICE_ID = '4' where OFFICE_ID = '10'

SET OFFICE_ID = '11' where OFFICE__ID = '3';

Thanks!


UPDATE [BULDING].[dbo].[TB_DATA]
SET OFFICE_ID = 
    case when office_id in ('8', '10') then '4'
        when office_id = '3' then '11'
        else office_id
    end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜