I'm wondering if anyone has any ideas of what to change in my query here. Currently it doesn't update any rows. Any ideas?
Code:
UPDATE gc SET gc.Balance = agc.S6CRBL - o.OrderTotal FROM GiftCard gc INNER JOIN @APLUSGiftCards agc ON gc.SerialNumber = agc.S6CRNO LEFT JOIN Orders o ON gc.SerialNumber = o.CouponCode WHERE gc.SerialNumber IN (SELECT SerialNumber FROM @WebGiftCards) AND o.CouponType = @CouponType AND ((o.PaymentMethod = 'PURCHASEORDER' AND o.TransactionState = 'PENDING') OR (o.PaymentMethod = 'CREDITCARD' AND o.TransactionState = 'AUTHORIZED'))
Do I need to loop to do the update instead?