Reputation: 1564
I have a table with following fields:
ID , FirstName , LastName , Count , Amount
Need something like this code :
IF EXISTS (SELECT * FROM [myDB] WHERE @ID = [ID])
set [count] = [count] + 1 and [Amount] = [Amount] - 1
Upvotes: 4
Views: 8090
Reputation: 1
UPDATE MST_SPR_donategifts SET Gift_Quantity = Gift_Quantity- @Gift_Quantity WHERE Gift_Code=@Gift_Code
Upvotes: 0
Reputation: 32602
Use simple update query like this:
UPDATE myDB
SET [count] = [count] + 1
, [Amount] = [Amount] - 1
WHERE ID = @ID
Upvotes: 3