Update Query in MySQL

Profile picture for user arilio666

If we want to modify an existing record in the table, then the update statement is the one we should go for.

MySQL Update Syntax

UPDATE table_name
SET column1 = value, column2 = value, ...
WHERE condition;

MySQL Update Example

Let us use the info table for this example demonstration.

MySQL Update Example

Now let us modify the city of Aldo to Chennai instead of Bombay. Let us see how we can do that.

SET city = 'Chennai'
WHERE Name = 'Aldo';

MySQL Update Statement Example

We can see here that we have changed the city of Aldo to Chennai using the update.


SET city = 'Chennai'

Without a where statement in the update statement query, this above query will change the record of everything to Chennai regardless of the where statement.

This is how we can use the update statement effectively.