MySQL UPDATE Statement

Published: 22 December 2025
on channel: Learn With Passion
14
3

Updating data is one of the most important tasks when you work with the database. In this tutorial, you will learn how to use the MySQL UPDATE statement to update data in a table.

The UPDATE statement updates data in a table. It allows you to change the values in one or more columns of a single row or multiple rows.

In this example, we will update the email of dmurphy@classicmodelcars.com to the new email dmurphy@gmail.com


update the email address of Mary to the new email mary.patterson@classicmodelcars.com :
UPDATE employees
SET
email = 'mary.patterson@classicmodelcars.com'
WHERE
employeeNumber = 1056;
Code language: SQL (Structured Query Language) (sql)
MySQL issued the number of rows affected:

1 row(s) affected
In this UPDATE statement:

The WHERE clause specifies the row with employee number 1056 will be updated.
The SET clause sets the value of the email column to the new email.

In this UPDATE statement:
The WHERE clause specifies the row with employee number 1056 will be updated.
The SET clause sets the value of the email column to the new email.

MySQL UPDATE to modify values in multiple columns:
o update values in the multiple columns, you need to specify the assignments in the SET clause. For example, the following statement updates both last name and email columns of employee number 1056.

UPDATE employees
SET
lastname = 'Hill',
email = 'mary.hill@classicmodelcars.com'
WHERE
employeeNumber = 1056;

MySQL UPDATE to replace string example:
The following example updates the domain parts of emails of all Sales Reps with office code 6:

UPDATE employees
SET email = REPLACE(email,'@classicmodelcars.com','@mysqltutorial.org')
WHERE
jobTitle = 'Sales Rep' AND
officeCode = 6;
Code language: SQL (Structured Query Language) (sql)
In this example, the REPLACE() function replaces @classicmodelcars.com in the email column with @mysqltutorial.org.


On this page of the site you can watch the video online MySQL UPDATE Statement with a duration of hours minute second in good quality, which was uploaded by the user Learn With Passion 22 December 2025, share the link with friends and acquaintances, this video has already been watched 14 times on youtube and it was liked by 3 viewers. Enjoy your viewing!