How to UPDATE Data in MySQL

To update table data, you can use the UPDATE statement. The syntax is as follows:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

In this case, table_name refers to the name of the table where data will be modified. Following the SET keyword is the column name and its corresponding value that needs to be changed. The WHERE clause is used to specify the filtering criteria, and only the rows that meet the condition will be modified. For example:

UPDATE users
SET name = 'Alice', age = 30
WHERE id = 1;

This statement will change the name of the user with ID 1 to Alice and the age to 30.

bannerAds