UPDATE

If you want to change data in a table or just in some rows—even one row only—use this MySQL statement. Click on the heading here for more details.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

UPDATE [LOW_PRIORITY] [IGNORE] table
SET column=expression[, ...] 
[WHERE condition] 
[ORDER BY {column|expression|position}[ASC|DESC], ...] 
[LIMIT {[offset,] count|count OFFSET offset}]

UPDATE [LOW_PRIORITY] [IGNORE] table_reference 
     SET column=expression[, ...] 
     [WHERE condition]

Explanation

This statement changes existing rows of data in a table. The first syntax shown updates only one table per statement (see UPDATE a Single Table). The second syntax can be used to update or reference data in multiple tables from one statement (see UPDATE Multiple Tables). Explanations of both types of statements and examples of their use follow.