#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 4
4 min read

UPDATE Operations

Modify existing data in your database tables.

What is UPDATE?

UPDATE changes existing data in a table. Use it when you need to modify values that are already stored.

The Syntax

UPDATE table_name SET column = new_value WHERE condition;

Example: Change a Grade

Before: (see table below)

students table - Before UPDATE
idnameagegrade
1Alice20A
2Bob22B
3Charlie21A
3 rows
UPDATE students SET grade = 'A+' WHERE id = 1;

After: Alice's grade changes from 'A' to 'A+'

Update Multiple Columns

UPDATE students SET grade = 'A', age = 21 WHERE id = 2;

Changes both grade AND age for Bob.

How UPDATE Works (Step by Step)

Step 1: Write UPDATE and table name

Step 2: Write SET with column = new value

Step 3: Write WHERE to specify which rows

Step 4: Add semicolon ;

UPDATE students -- Step 1 SET grade = 'A+' -- Step 2 WHERE id = 1; -- Step 3 & 4

WARNING: Always Use WHERE!

Without WHERE, ALL rows get updated:

UPDATE students SET grade = 'F'; -- DANGER: Everyone gets F!

Always add WHERE:

UPDATE students SET grade = 'F' WHERE id = 1; -- Safe: Only id=1 gets F

Quick Reference

  • UPDATE table SET col = val WHERE condition - Update specific rows
  • SET col1 = val1, col2 = val2 - Update multiple columns
  • Always use WHERE to avoid updating all rows!

Tip: Test your WHERE clause with SELECT first to see which rows will be affected!

Try UPDATE

Change the WHERE condition or SET values and see the table update

Current Table: students
idnameagegrade
1Alice20A
2Bob22B
3Charlie21A
3 rows
SQL Editor
Loading...

Finished this topic?

Mark it complete to track your progress and maintain your streak!

SkillsetMaster - AI, Web Development & Data Analytics Courses