From the course: SQL Practice: Updating Data with UPDATE Statements

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Basic UPDATE

Solution: Basic UPDATE

(bright electronic music) - [Instructor] In this exercise, you are tasked to update the Products table by setting a new price for all products in the Accessories category. Let's go through the solution step by step. We start with the basic structure of the update statement, UPDATE Products. This indicates that we're going to update data in the Products table. Next, we use the SET clause to specify the new price for the products in the Accessories category. SET Price = 149.99. This line sets the price to 149.99 for all products we're targeting. Now, to ensure that we only update products in the Accessories category, we add a WHERE clause. This condition restricts the update to only those rows where the category is Accessories. Now, when this query runs, SQL will search the Products table for rows where the category is Accessories, then it'll update the price for those rows to 149.99. To verify that the update was successful, you can run the following SELECT statement. This query will…

Contents