UPDATE Payment payment SET payment.amount =(payment.amount + :amount) WHERE payment.id =:personId
要在相同的列字段中更新累积总和。也就是说,"付款"付款表中的字段应使用" amount + payment"的附加值进行更新。在同一领域。但上面的查询创造了" payment"每次在新行中使用"金额"值。
我在这里缺少什么?
答案 0 :(得分:0)
试试这个:
UPDATE Payment payment, (select @amount:=:amount) as a
SET payment.amount =(@amount:=@amount + payment.amount)
WHERE payment.id =:personId;