MySQL UPDATE Statement (original) (raw)

Last Updated : 25 Mar, 2026

The UPDATE statement in MySQL is used to modify existing records in a table and update column values as needed. It helps in correcting errors and keeping data accurate.

**Syntax:

UPDATE table_name SET column_name = value WHERE (condition);

**Note: Always use the WHERE clause with an UPDATE statement to target specific records. Without it, all rows in the table will be updated, which may lead to unintended data changes.

Working with MySQL UPDATE Statement

Let’s look at some examples of the UPDATE statement in MySQL to understand how it works and its different use cases. First, we will create a demo table on which the UPDATE statement will be applied:

Screenshot-2026-03-25-094547

geeksforgeeks Table

Example 1: UPDATE Statement with Single Column

This example updates a single column value for a specific row using the WHERE clause. It ensures only the targeted record is modified.

**Query:

UPDATE geeksforgeeks SET contest_rank = 10 WHERE id = 'user3003';

SELECT * FROM geeksforgeeks;

**Output:

Screenshot-2026-03-25-095611

Example 2: UPDATE Statement with Multiple Columns

This example updates multiple columns in a single query for a specific record. It helps modify related data together efficiently.

**Query:

UPDATE geeksforgeeks SET contest_rank = 55, courses_enrolled = 15 WHERE id = 'user3004';

SELECT * FROM geeksforgeeks;

**Output:

Screenshot-2026-03-25-095813

Example 3: UPDATE Statement with String Values

This example updates a string value in a column for a specific row. It is useful when modifying text-based data.

**Query:

UPDATE geeksforgeeks SET name = 'Alexander' WHERE id = 'user3001';

SELECT * FROM geeksforgeeks;

**Output:

Screenshot-2026-03-25-100139

Example 4: UPDATE Statement Without WHERE Clause

This example updates all rows in the table by modifying a column value. It is useful for bulk updates but should be used carefully.

**Query:

UPDATE geeksforgeeks SET monthly_score = monthly_score + 1;

SELECT * FROM geeksforgeeks;

**Output:

Screenshot-2026-03-25-100431

Example 5: UPDATE Statement with Complex Query

This example updates multiple rows based on multiple conditions using logical operators. It helps apply changes to selected records.

**Query:

UPDATE geeksforgeeks SET contest_rank = contest_rank + 5, courses_enrolled = courses_enrolled + 10 WHERE id = 'user3001' OR name = 'Sophia';

SELECT * FROM geeksforgeeks;

**Output:

Screenshot-2026-03-25-100644

IGNORE Clause with UPDATE Statement

The IGNORE clause is used with the UPDATE statement in some database systems like MySQL. It allows users to control error handling during the update process.

**Syntax:

UPDATE IGNORE table_name SET column1 = 'new value' WHERE column2 = 'condition';

**Query:

UPDATE IGNORE geeksforgeeks SET id = 'user3001' WHERE contest_rank > 3;