GNU Info

Info Node: (mysql.info)UPDATE

(mysql.info)UPDATE


Next: DELETE Prev: INSERT DELAYED Up: Data Manipulation
Enter node , (file) or (file)node

`UPDATE' Syntax
---------------

     UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
         SET col_name1=expr1, [col_name2=expr2, ...]
         [WHERE where_definition]
         [LIMIT #]

`UPDATE' updates columns in existing table rows with new values.  The
`SET' clause indicates which columns to modify and the values they
should be given.  The `WHERE' clause, if given, specifies which rows
should be updated.  Otherwise all rows are updated. If the `ORDER BY'
clause is specified, the rows will be updated in the order that is
specified.

If you specify the keyword `LOW_PRIORITY', execution of the `UPDATE' is
delayed until no other clients are reading from the table.

If you specify the keyword `IGNORE', the update statement will not
abort even if we get duplicate key errors during the update.  Rows that
would cause conflicts will not be updated.

If you access a column from `tbl_name' in an expression, `UPDATE' uses
the current value of the column.  For example, the following statement
sets the `age' column to one more than its current value:

     mysql> UPDATE persondata SET age=age+1;

`UPDATE' assignments are evaluated from left to right.  For example, the
following statement doubles the `age' column, then increments it:

     mysql> UPDATE persondata SET age=age*2, age=age+1;

If you set a column to the value it currently has, MySQL notices this
and doesn't update it.

`UPDATE' returns the number of rows that were actually changed.  In
MySQL Version 3.22 or later, the C API function `mysql_info()' returns
the number of rows that were matched and updated and the number of
warnings that occurred during the `UPDATE'.

In MySQL Version 3.23, you can use `LIMIT #' to ensure that only a
given number of rows are changed.


automatically generated by info2www version 1.2.2.9