I need to use ON DUPLICATE KEY to increment columns in my table by a set amount. How would I go about getting the current value of the column and incrementing it by X amount.
Note: I'm using the nodejs mysql package and this is my code currently:
db.query(`INSERT INTO some_table SET ? ON DUPLICATE KEY UPDATE ?`, [
{
sessions: 25,
pageviews: 240
},
{
sessions: `sessions + ${sessionsIncrementAmount}`,
pageviews: `pageviews + ${pageviewsIncrementAmount}`
}
])