Back to SQL Notes
Topic #78

SQL UPDATE Statement

UPDATE modifies existing rows in a table.

Syntax

UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;

Example

UPDATE employees
SET salary = 75000
WHERE name = 'Karan';

Only Karan's row changes. Every other row is untouched.

Updating Multiple Columns

UPDATE employees
SET department = 'Senior Engineering', salary = salary * 1.10
WHERE department = 'Engineering' AND salary > 60000;

Note salary = salary * 1.10 — you can reference the column's current value inside its own update.

The One Rule That Matters Most: Never Forget WHERE

-- DANGEROUS: updates every single row in the table
UPDATE employees
SET salary = 75000;

Without a WHERE clause, UPDATE applies to every row. This is the single most common — and most damaging — SQL mistake in real production systems. Always write and double-check your WHERE clause before running an UPDATE, especially outside a transaction.

Safer Habit: Check with SELECT First

-- Step 1: confirm exactly which rows will be affected
SELECT * FROM employees WHERE department = 'Engineering' AND salary > 60000;

-- Step 2: only then run the UPDATE with the same WHERE clause

Dialect Note: UPDATE with a JOIN

-- MySQL
UPDATE orders o
JOIN customers c ON o.customer_id = c.id
SET o.customer_tier = c.tier
WHERE c.tier = 'gold';

-- PostgreSQL (different syntax — uses FROM)
UPDATE orders o
SET customer_tier = c.tier
FROM customers c
WHERE o.customer_id = c.id AND c.tier = 'gold';

Common Mistakes

  • Running UPDATE without WHERE (see above)
  • Updating a column used inside the same WHERE clause and getting unexpected results depending on evaluation order
  • Not wrapping risky updates in a transaction so a mistake can be rolled back (see Transactions)

Interview Relevance

Expect scenario questions like "give every employee in Sales a 10% raise" — testing whether you remember the WHERE clause and correct arithmetic on the existing column value.

Practice Question

Write a statement to increase the price of all products in the "Electronics" category by 5%.

Want to go beyond the notes?

Join Coding Now Tech Institute's SQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

SQL UPDATE Statement – FAQs

Quick answers about learning SQL UPDATE Statement in SQL.

This free note from Coding Now Tech Institute explains SQL UPDATE Statement in SQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every SQL topic on Coding Now Tech Institute, including SQL UPDATE Statement, is 100% free with no signup required.
With focused practice, most students grasp SQL UPDATE Statement in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now