How to update field to add value to existing value?
For example I have
Table name: table
id credit
1 4
2 5
3 3
I wanted to add to this with an 'ON DUPLICATE KEY UPDATE' example(based on the answer by @hims056). I found this answer but needed 'ON DUP...' so I figured may as well post it here.
INSERT INTO table1
(`id`, `credit`)
VALUES (1, 4)
ON DUPLICATE KEY UPDATE
`credit` = `credit` + 7;
See the SQL Fiddle here