PHP mysqli on duplicate key update
Go to solution
Solved by zwirek2201,
Just now, Joveice said:Oh, yea the id is primary, can I keep that to work as a id and change pname to primary without breaking anything? (id is not used for anything else than keeping each table unique what so ever)
You can keep your primary key as it is and add "unique" identifier to the pname field (second option on the right side
) and it should work. Essentially, the "ON DUPLICATE KEY UPDATE" will update the row if you're trying to insert a row with a duplicate primary key value or with duplicate value on any column that has the "unique" identifier set.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now