Skip to content

Commit

Permalink
fixup! added syntax reference for ON DUPLICATE KEY clause
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Bogensberger committed Jan 22, 2015
1 parent 918bb67 commit 8686357
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions docs/sql/reference/insert.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ Synopsis
[ ( column_ident [, ...] ) ]
{ VALUES ( expression [, ...] ) [, ...] | query }
[ ON DUPLICATE KEY UPDATE
{ column_ident = expression |
( column_ident [, ...] ) = ( expression [,...] )
} [, ...]
{ column_ident = expression } [, ...]
]

Description
Expand All @@ -44,22 +42,21 @@ On Duplicate Key Update
-----------------------

If ``ON DUPLICATE KEY UPDATE`` is specified and a row is inserted that
would cause a duplicate PRIMARY KEY value, an update of the existing
would cause a duplicate-key conflict, an update of the existing
row is performed.

::

ON DUPLICATE KEY UPDATE
{ column_ident = expression |
( column_ident [, ...] ) = ( expression [,...] )
} [, ...]
ON DUPLICATE KEY UPDATE { column_ident = expression } [, ...]

Within expressions in the ``UPDATE`` clause you can use the
``VALUES(column_ident)`` function to refer to column values
from the INSERT statement.
So ``VALUES(column_ident)`` in the ``UPDATE`` clause referes to the
value of the column_ident that would be inserted if no duplicate-key
conflict occured.
This function is especially useful in multiple-row inserts, because
the values of the current row can be referenced.

Parameters
==========
Expand Down

0 comments on commit 8686357

Please sign in to comment.