Name
UPDATE
Syntax
UPDATE [LOW_PRIORITY] [IGNORE]table
SETcolumn
=value
, ... [WHEREclause
] [LIMITn
]
Description
Alters data within a table. You may use the name of a column as a
value when setting a new value. For example, UPDATE health
SET miles_ran=miles_ran+5
would add five to the current
value of the miles_ran
column.
The syntax and common operators of the WHERE
clause are shown in Chapter 3. The
WHERE
clause limits updates to matching rows. The
LIMIT
clause ensures that only
n rows change. The statement returns the number
of rows changed.
You must have UPDATE
privileges to use this
statement.
Example
# Change the name 'John Deo' to 'John Doe' everywhere in the people table. UPDATE people SET name='John Doe' WHERE name='John Deo'
Get Managing & Using MySQL, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.