我正在更新具有特定列的一些新值的表,如下所示,所以我在prepayId指示的某些流量上更新了表Prepay,列PrepayTransactionDesc
update Prepay set PrepayTransactionDesc = 'Funded Repeat Voucher 153429' where prepayId = 58045
它工作正常,但我想进行多次更新。我尝试了几种不同的方法,但是失败了。那是我试图做到的,时不时地使用CASE。
例如,我有以下prepayid和prepaytransactiondesc字段
57770 Funded Repeat Voucher 153118 57771 Funded Repeat Voucher 153119 57772 Funded Repeat Voucher 153120 57773 Funded Repeat Voucher 153121 57774 Funded Repeat Voucher 153122 57775 Funded Repeat Voucher 153123 57776 Funded Repeat Voucher 153124 57894 Funded Repeat Voucher 153276 57895 Funded Repeat Voucher 153277 57896 Funded Repeat Voucher 153278
我怎么做他们一口气?不可能那么困难,但是当我尝试执行任务时,我似乎缺少了一些东西。
你可以试试
UPDATE Prepay SET PrepayTransactionDesc = CASE WHEN prepayID = 57770 THEN 'Funded Repeat Voucher 153118' WHEN prepayID = 57771 THEN 'Funded Repeat Voucher 153119' WHEN prepayID = nextID THEN 'Next Value' END WHERE prepayID in (1,2,4,57770... all your ids here)