GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • SQL
  • Projects
  • Interview Questions
  • Quiz
  • DBMS
  • PostgreSQL
  • Django
  • ReactJS
  • Vue.js
  • AngularJS
  • API
  • REST API
  • SQL3 min read
  • Data Types3 min read

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — SQL UPDATE Statement - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • SQL
  • Projects
  • Interview Questions
  • Quiz
  • DBMS
  • PostgreSQL
  • Django
  • ReactJS
  • Vue.js
  • AngularJS
  • API
  • REST API

SQL UPDATE Statement

Last Updated : 29 Aug, 2026

The SQL UPDATE statement is used to modify existing data in a table by changing the values of one or more columns.

  • The WHERE clause specifies which rows should be updated.
  • Without WHERE, all rows in the table are modified.

Syntax

UPDATE table_name
SET column1 = value1,
column2 = value2
WHERE condition;
  • table_name: Name of the table you want to update.
  • SET: The column(s) you want to update and their new values.
  • WHERE: Filters the specific rows you want to update.

Note: The SET keyword assigns new values to columns, while the WHERE clause selects which rows to update. Without WHERE, all rows will be updated.

Working

Consider the customer table shown below, which contains each customer’s unique ID, name, last name, phone number and country. This table will be used to demonstrate how the SQL UPDATE statement works.

Screenshot-2026-08-20-122830

Example 1: Update Single Column

We have a customer table and we want to update the Age to 25 for the customer whose customer_name is 'Isabella'.

Query:

UPDATE customer
SET age = 25
WHERE customer_name = 'Isabella';
SELECT * FROM customer;

Output:

Screenshot-2026-08-20-122548
  • The query updates the age to 25 for the customer named 'Isabella'.
  • It affects only the row where customer_name = 'Isabella'.
  • It is used to modify existing data in a specific record.

Example 2: Updating Multiple Columns

We need to update both the customer_name and country for a specific customer_id.

Query:

UPDATE customer 
SET customer_name = 'John',
country = 'Spain'
WHERE customer_id = 1;

Output:

Screenshot-2026-08-20-122621
  • The query targets the row where customer_id = 1.
  • It updates customer_name to 'John' and country to 'Spain'.
  • Both columns are updated simultaneously in a single SQL statement.

Note: For updating multiple columns we have used comma( , ) to separate the names and values of two columns.

Example 3: Omitting WHERE Clause in UPDATE Statement

If we accidentally omit the WHERE clause, all the rows in the table will be updated, which is a common mistake. Let’s update the customer_namefor every record in the table:

Query:

UPDATE customer
SET customer_name = 'Mike';
SELECT * FROM customer;

Output:

Screenshot-2026-08-20-123350
  • Updates the customer_name to 'Mike' for all rows in the customer table.
  • It affects every record because no WHERE clause is used.
Comment

Explore

    Basics
    • SQL3 min read
    • Data Types3 min read
    • Operators4 min read
    • Commands5 min read
    • Database Operations2 min read
    • CREATE TABLE2 min read
    Queries & Operations
    • SELECT Query2 min read
    • INSERT INTO3 min read
    • UPDATE2 min read
    • DELETE2 min read
    • WHERE2 min read
    • Aliases2 min read
    Joins & Functions
    • Joins3 min read
    • CROSS JOIN1 min read
    • Date Functions2 min read
    • String functions4 min read
    Data Constraints & Aggregate Functions
    • NOT NULL Constraint3 min read
    • PRIMARY KEY3 min read
    • Count()4 min read
    • SUM()2 min read
    • MAX()3 min read
    • AVG()2 min read
    Advanced SQL Topics
    • Subquery4 min read
    • Window Functions4 min read
    • Stored Procedures3 min read
    • Triggers4 min read
    • Performance Tuning4 min read
    • TRANSACTIONS4 min read
    Database Design & Security
    • ER Model9 min read
    • Normalization2 min read
    • Keys in Relational Model7 min read
    • SQL Injection10 min read
    • Data Encryption3 min read
    • SQL Backup4 min read
    • ORM in DBMS5 min read
    Courses
    • Placement 360 Course2 min read
    • Data Science 360 Course2 min read
    • MERN Full Stack Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.