我有一个包含以下字段的表格:
ID , FirstName , LastName , Count , Amount
需要类似这样的代码:
IF EXISTS (SELECT * FROM [myDB] WHERE @ID = [ID])
set [count] = [count] + 1 and [Amount] = [Amount] - 1
答案 0 :(得分:4)
使用这样的简单更新查询:
UPDATE myDB
SET [count] = [count] + 1
, [Amount] = [Amount] - 1
WHERE ID = @ID
答案 1 :(得分:0)
更新MST_SPR_donategifts SET Gift_Quantity = Gift_Quantity- @Gift_Quantity 在哪里Gift_Code = @ Gift_Code