paul bennett

MySQL insert or update in one query

Posted on: October 29, 2007

Another MySQL timesaver:
INSERT INTO Sales(TransId, Status, Amount)
VALUES(123, 'Pending', 20)
ON DUPLICATE KEY UPDATE Status = 'Paid'

Via Particletree

————

Need to improve your MySQL skills? I recommend:
High Performance MySQL: Optimization, Backups, Replication, and More

Leave a comment

Archives