I want to put data in a third table based from two other tables. But if the user already exist I just want to update the users points. I've looked at ON DUPLICATE KEY UPDATE but don't understand how to implent it with my Insert.
INSERT INTO toplist( user_id, name, lastname, points )
SELECT O.user_id, name, lastname, SUM( points ) AS points
FROM userdata AS C, predictions AS O
WHERE O.lid =2020
AND C.user_id = O.user_id
GROUP BY O.user_id