The UPDATE statement is used to update existing records in a table. The UPDATE statement is always used in combination with clauses and operators.

Syntax

UPDATE [LOW_PRIORITY] [IGNORE] table_name SET column1=value, column2=value2,... WHERE some_column=some_value;

 

To protect the database from errors, MySQL will not execute an UPDATE statement if there are any errors in the syntax, but rather will generate an alarm.

In the example above, the keyword LOW_PROIRITY is used to delay the execution till no other connections read data from the table, while the keyword IGNORE is used to override error warnings and execute the command anyway.

Following example shows a more realistic MySQL table update:

UPDATE emp SET eName='SMITH', Sal=5000 WHERE eName='JONES' AND city='Los Angeles';

Note: The UPDATE statement in MySQL always comes with the SET clause which is used to set new values for selected columns.