SQL UPDATE

Change existing rows.

✍️ 3 exercises + code challenge in this lesson

UPDATE changes existing records:

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

Be careful! Without a WHERE clause, every row in the table is updated.

Key Takeaways: SQL UPDATE

Mastering SQL UPDATE helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

SQL UPDATE Code Example

SQL
UPDATE Products
SET Price = Price * 0.9
WHERE Category = 'Furniture';

UPDATE Customers
SET Email = 'usman@electronics.pk', City = 'Rawalpindi'
WHERE CustomerID = 3;

SELECT ProductName, Price FROM Products WHERE Category = 'Furniture';
SELECT * FROM Customers WHERE CustomerID = 3;
Free sign-in required · Google login available

SQL UPDATE Practice Exercises

Check what you learned in “SQL UPDATE”.

/ 3 solved
Fill in the blank

Change the city of customer 7.

 Customers  City = 'Sialkot' WHERE CustomerID = 7;
✓ Correct! Not quite. Try again.
Multiple choice

What happens if you run UPDATE without WHERE?

✓ Correct! Not quite. Try again.
Code challenge

Set the Stock of the Bookshelf (ProductID 9) to 5, then select ProductName, Stock for ProductID 9.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services