SyntaxStudy
Sign Up
MySQL Beginner 4 min read

SQL UPDATE Syntax

The SQL UPDATE statement is used to modify existing records in a table. It is one of the core DML (Data Manipulation Language) commands and is essential for keeping your data current and accurate.

Basic Syntax

The basic syntax of the UPDATE statement requires you to specify the table name, the columns to change with their new values using the SET clause, and a WHERE clause to identify which rows to update.

Without a WHERE clause, all rows in the table will be updated — so always double-check your condition before running the query.

How It Works

MySQL scans the table for rows that match the WHERE condition. For each matching row, it replaces the old column values with the new ones you specify in the SET clause. Multiple columns can be updated in a single statement by separating each assignment with a comma.

  • SET assigns new values to one or more columns
  • WHERE filters which rows are affected
  • Multiple columns can be updated simultaneously
  • Expressions and subqueries are allowed as new values
Example
UPDATE customers
SET city = 'Oslo'
WHERE customer_id = 1;
Pro Tip

Always use WHERE with UPDATE to avoid updating all rows in the table.