The UPDATE statement in MySQL is used to modify existing records in a table. The basic syntax of the UPDATE statement is as follows:
UPDATE table_name
SET column1=value1, column2=value2, ...
WHERE condition;
In this syntax:
table_name
is the name of the table you want to update.column1
,column2
, etc. are the names of the columns you want to update.value1
,value2
, etc. are the new values you want to set for those columns.condition
specifies which rows should be updated. If omitted, all rows in the table will be updated.
For example, suppose we have a table named “employees” with columns “id”, “name”, and “salary”. We can use the following UPDATE statement to increase the salary of all employees whose id is greater than 100:
UPDATE employees
SET salary=salary*1.05
WHERE id>100;