UPDATE

Syntax:

UPDATE [LOW PRIORITY] [IGNORE] table_name
  SET column_name1=expression1, column_name2=expression2,...
  [WHERE where_definition]
  [LIMIT num]

Description: Modifies the values held in existing rows in a table.

The SET portion defines the new values for the named columns, which will be updated to expression where the rows match the where_definition.

By specifying LOW_PRIORITY, the update does not take place until no other clients are reading from the table.

Using IGNORE, the statement keeps processing even if a modification occurs that tries to infringe a primary or unique key.

Specifying LIMIT restricts the maximum number of rows that may be affected by the update to num.

Description in: Day 7

See also: INSERT, DELETE

Get Sams Teach Yourself MySQL in 21 Days, Second 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.