Too many auto increments with ON DUPLICATE KEY UPDATE
Solution 1:
I don't think there is a way to bypass this behaviour of INSERT ... ON DUPLICTE KEY UPDATE
.
You can however put two statements, one UPDATE
and one INSERT
, in one transaction:
START TRANSACTION ;
UPDATE pages
SET etc = 'randomness'
WHERE name = 'bob' ;
INSERT INTO pages (name, etc)
SELECT
'bob' AS name
, 'randomness' AS etc
FROM dual
WHERE NOT EXISTS
( SELECT *
FROM pages p
WHERE p.name = 'bob'
) ;
COMMIT ;