Hi I’m trying to execute an INSERT AND UPDATE ON DUPLICATE KEY just for a specific user ID, my primary key is privacy_id so far I’ve tried:

INSERT INTO privacy (privacy_id, user_id, privacy_ref, privacy_value)
                VALUES (:privacyID, :userID, :privacyRef, :privacyValue)
                ON DUPLICATE KEY UPDATE privacy_value = :newPrivacyValue
WHERE user_id = :storedUserID

But searching online I’ve discovere it is not possible to use WHE clause with ON DUPLICATE KEY UPDATE is there another way to achieve it? Many thanks

What is the primary key of the privacy table? If it is user_id then you can just drop the WHERE and keep the rest of the query AFAIK.

Hi @rpkamp

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.