I have a table playerspoints
that contains a shop id and a player's id, and a player's points.
SHOP_ID | PLAYER_ID | POINTS
----------------------------------------
1 | 7 | 66
2 | 4 | 33
What I want to do is transfer points from a shop to the other.
- Problem: shop id and players id form a unique index.
- What I want to do is on duplicate key update, instead of let it fail, to add the points of one entry to the other and delete the "from" entry.
Something like:
UPDATE `playerspoints`
SET `boardId`=$to
WHERE `boardId`=$from
ON DUPLICATE KEY UPDATE `points`=....
Do you get the idea?