Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
You should first understand the definition of a key.
A key is used to identify a row in the table and/or aid with performance when sorting or grouping. The most common type of key is the primary key and every table should have one. The primary key uniquely identifies each row in the table. If you try to insert a new row with a value for the primary key that already exists you will get an appropriately named "duplicate key" error. The "on duplicate key" clause catches that error and instead opts to update some values in the row that already exists.
Posts: 680
Threads: 143
Joined: Nov 2014
Reputation:
0
So instead from inserting new row it updates the one which have the same data?
Posts: 3,324
Threads: 96
Joined: Sep 2013
Quote:
Originally Posted by nezo2001
So instead from inserting new row it updates the one which have the same data?
|
No it won't do anything if a key clashes, it returns an error. If you want to update use "UPDATE".
Posts: 826
Threads: 64
Joined: Oct 2013
Reputation:
0
Use update statements if you wish to update