SQL UPDATE Statement – Complete Beginner's Guide with Examples (2026-27)
The SQL UPDATE statement is a Data Manipulation Language (DML) command used to modify existing records in a database table. You can update one column, multiple columns, or even all rows — always using the WHERE clause to target only the rows you need. In this beginner-friendly guide you will learn the UPDATE syntax, see step-by-step examples with before/after result tables, understand how to update multiple columns at once, and learn the critical safety rules to avoid updating the wrong rows.
✅ What is SQL UPDATE?
The SQL UPDATE statement is used to change the values of one or more columns in existing rows of a table. It is one of the four core DML (Data Manipulation Language) operations in SQL alongside SELECT, INSERT, and DELETE.
✅ UPDATE modifies existing rows — it does NOT add new rows (that is INSERT) or remove rows (that is DELETE).
✅ The WHERE clause controls which rows are updated. Without it, ALL rows in the table are updated.
✅ SQL UPDATE Syntax
✅ Basic Syntax:-
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
✅ UPDATE:- Specifies the table you want to modify.
✅ SET:- Lists the columns and their new values, separated by commas.
✅ WHERE:- Filters which rows to update. Without WHERE, ALL rows are updated.
✅ SQL UPDATE – Quick Reference Table
| Scenario | Syntax | Notes |
|---|---|---|
| Update one column | UPDATE t SET col1 = v1 WHERE condition | Only col1 is changed; other columns untouched |
| Update multiple columns | UPDATE t SET col1 = v1, col2 = v2 WHERE condition | Separate pairs with a comma |
| Update all rows | UPDATE t SET col1 = v1 | ⚠️ Dangerous — no WHERE means ALL rows change |
| Update with AND | UPDATE t SET col1 = v1 WHERE c1 = x AND c2 = y | Targets rows matching both conditions |
| Update using calculation | UPDATE t SET Salary = Salary + 1000 WHERE Dept = 'IT' | Add/multiply/subtract from existing value |
🔸 Starting Employees Table (used in all examples below)
| ID | Name | Department | Salary | City |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | Mumbai |
| 2 | POOJA | IT | 9000 | Pune |
| 3 | RAJ | SALES | 5000 | Delhi |
| 4 | SUJAN | HR | 8000 | Pune |
| 5 | MEENA | SALES | 12000 | Mumbai |
✅ Example 1 – Update One Column
Update POOJA's salary from 9000 to 11000:
UPDATE QueryUPDATE Employees
SET Salary = 11000
WHERE Name = 'POOJA';
✅ Result Show:-
| ID | Name | Department | Salary | City |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | Mumbai |
| 2 | POOJA | IT | 11000 ✅ | Pune |
| 3 | RAJ | SALES | 5000 | Delhi |
| 4 | SUJAN | HR | 8000 | Pune |
| 5 | MEENA | SALES | 12000 | Mumbai |
Name = 'POOJA'.
✅ Example 2 – Update Multiple Columns at Once
Update SUJAN's salary AND city at the same time:
UPDATE QueryUPDATE Employees
SET Salary = 9500, City = 'Bangalore'
WHERE ID = 4;
✅ Result Show:-
| ID | Name | Department | Salary | City |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | Mumbai |
| 2 | POOJA | IT | 11000 | Pune |
| 3 | RAJ | SALES | 5000 | Delhi |
| 4 | SUJAN | HR | 9500 ✅ | Bangalore ✅ |
| 5 | MEENA | SALES | 12000 | Mumbai |
ID = 4 as the WHERE condition is the safest option — it targets exactly one unique row.
✅ Example 3 – Update All Rows in a Department
Give every SALES employee a 1000 salary increase:
UPDATE QueryUPDATE Employees
SET Salary = Salary + 1000
WHERE Department = 'SALES';
✅ Result Show:-
| ID | Name | Department | Salary | City |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | Mumbai |
| 2 | POOJA | IT | 11000 | Pune |
| 3 | RAJ | SALES | 6000 ✅ | Delhi |
| 4 | SUJAN | HR | 9500 | Bangalore |
| 5 | MEENA | SALES | 13000 ✅ | Mumbai |
Both RAJ (5000 → 6000) and MEENA (12000 → 13000) were updated because both are in SALES department.
✅ Example 4 – UPDATE with AND Condition
Update department to 'IT' only for employees in Pune with salary above 8000:
UPDATE QueryUPDATE Employees
SET Department = 'IT'
WHERE City = 'Pune' AND Salary > 8000;
✅ Result Show:-
| ID | Name | Department | Salary | City |
|---|---|---|---|---|
| 1 | ANNI | IT | 10000 | Mumbai |
| 2 | POOJA | IT ✅ | 11000 | Pune |
| 3 | RAJ | SALES | 6000 | Delhi |
| 4 | SUJAN | HR | 9500 | Bangalore |
| 5 | MEENA | SALES | 13000 | Mumbai |
✅ Example 5 – ⚠️ Dangerous: UPDATE Without WHERE
This example shows what happens when you forget the WHERE clause:
⚠️ DANGEROUS Query – DO NOT run without WHERE-- THIS UPDATES EVERY SINGLE ROW IN THE TABLE!
UPDATE Employees
SET Department = 'IT';
✅ Result Show (ALL rows changed – disaster!):-
| ID | Name | Department | Salary | City |
|---|---|---|---|---|
| 1 | ANNI | IT ⚠️ | 10000 | Mumbai |
| 2 | POOJA | IT ⚠️ | 11000 | Pune |
| 3 | RAJ | IT ⚠️ | 6000 | Delhi |
| 4 | SUJAN | IT ⚠️ | 9500 | Bangalore |
| 5 | MEENA | IT ⚠️ | 13000 | Mumbai |
Without a WHERE clause, UPDATE affects ALL rows. Always run a SELECT with the same WHERE condition first to preview which rows will be changed before running the UPDATE.
-- Step 1: Preview which rows will be affected
SELECT * FROM Employees WHERE Department = 'SALES';
-- Step 2: Only THEN run the UPDATE
UPDATE Employees
SET Salary = Salary + 1000
WHERE Department = 'SALES';
✅ Key Points to Remember
- ✅ Always use WHERE — without it, every row in the table is updated.
- ✅ Test with SELECT first — run
SELECT * FROM table WHERE your_conditionbefore UPDATE to preview affected rows. - ✅ Update multiple columns by separating them with a comma in SET:
SET col1 = v1, col2 = v2. - ✅ Use calculations in SET —
SET Salary = Salary + 1000adds 1000 to the current value. - ✅ Use AND / OR to combine multiple conditions in WHERE for precise targeting.
- ✅ Columns not listed in SET stay unchanged — UPDATE only modifies the columns you specify.
- ✅ Use ID in WHERE when possible —
WHERE ID = 4targets exactly one unique row, the safest option.
✅ Common SQL UPDATE Mistakes to Avoid
UPDATE Employees SET Salary = 5000; — updates ALL rows. Always add a WHERE condition. This mistake has caused many real production data disasters.
Wrong:
SET Department = IT — causes a syntax error.Correct:
SET Department = 'IT' — text values must be in single quotes.
SET Name = 'POOJA' WHERE ID = 2 vs SET Salary = 11000 WHERE ID = 2 — always double-check column names before running UPDATE. A typo in the column name causes an error; a correct column with wrong value causes silent data corruption.
Wrong:
WHERE City = NULL — always returns 0 rows.Correct:
WHERE City IS NULL
Wrong:
SET Salary = 11000 City = 'Mumbai' — syntax error.Correct:
SET Salary = 11000, City = 'Mumbai' — always separate column updates with a comma.
✅ Frequently Asked Questions (FAQ)
UPDATE Employees SET Salary = 12000, City = 'Mumbai' WHERE ID = 1; — this updates both Salary and City for employee with ID 1 in a single statement.SELECT * FROM Employees WHERE Department = 'SALES'; — this shows you exactly which rows will be affected. Only after confirming those are the right rows, run the UPDATE with the same WHERE clause.UPDATE Employees SET Salary = 15000 WHERE Department = 'IT' AND City = 'Pune'; — this updates only IT employees who are also in Pune. Both conditions must be true when using AND.