我有两张 table
bill
(id,amount,points)
bill_history
(id,bill_id,amount,points)
当一行插入 bill_history 时,我想汇总 bill_history 表中的金额和积分,并且应根据 bill_id 在账单表中更新
最佳答案
试试这个方法:
INSERT INTO YourTable(columns....)
VALUES(..........)
SET v_lastinsertedrecord = LAST_INSERT_ID()
UPDATE YourTable SET (COLUMNS='value') WHERE id=@lastinsertedrecord
关于mysql - 我想在将一行插入另一个表后更新mysql中的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45979249/