Beginner

712. UPDATE with WHERE

Learn how to update only selected records by using the WHERE clause.

📘 Lesson 711 of 728 ⏱ 7 min 🎯 Beginner

The WHERE clause limits the UPDATE statement to only those rows that satisfy the specified condition. Without WHERE, every record is modified.

Most business updates apply only to specific customers, employees, products, or transactions. WHERE prevents accidental updates to every row.

Only employees working in the IT department receive a salary increase.

SQL
UPDATE Employees
SET Salary = Salary + 5000
WHERE Department = 'IT';

Organizations update selected customers, active employees, pending orders, inventory items, and financial transactions using conditional updates.

  • Updates only matching rows.
  • Uses a WHERE clause.
  • Prevents accidental bulk updates.
  • Supports multiple conditions.
  • Works with comparison operators.
  • Can use AND and OR.
  • Always verify conditions before execution.
Why is WHERE important in UPDATE?

WHERE limits the update to selected records instead of updating the entire table.

How can you verify records before updating them?

Run a SELECT statement using the same WHERE condition before executing UPDATE.

Have you finished this lesson?

Introduction to SQL – All Lessons