How can I update multiple tables with an insert? What I’m trying here doesn’t work. Also, how can I add/subtract u.score with the difference between a vote variable and the existing v.weight?
INSERT INTO votes (userid, publication_id, weight) VALUES (1,2,3)
ON DUPLICATE KEY
UPDATE votes v, users u
SET v.weight=1
WHERE v.userid=1
--TODO: update u.score
It sounds like you probably want to use a trigger:
http://dev.mysql.com/doc/refman/5.0/en/triggers.html
Alternatively, you could encapsulate your initial insert, your logic, and any subsequent inserts into a stored procedure:
http://dev.mysql.com/doc/refman/5.0/en/stored-routines.html