Update All Rows or Columns in a Table3:01 with Andrew Chalkley
Sometimes you need to use SQL to update values in all rows or columns of a table, whether to fix an error, update a status, or something else. This video will show you how to update data in SQL.
An update statement for all rows:
UPDATE <table> SET <column> = <value>;
= sign is different from an equality operator from a
WHERE condition. It's an assignment operator because you're assigning a new value to something.
UPDATE users SET password = "thisisabadidea"; UPDATE products SET price = 2.99;
Update multiple columns in all rows:
UDPATE <table> SET <column 1> = <value 1>, <column 2> = <value 2>;
UPDATE users SET first_name = "Anony", last_name = "Moose"; UPDATE products SET stock_count = 0, price = 0;
See all of the SQL used in Modifying Data With SQL in the Modifying Data With SQL Cheatsheet.
You need to sign up for Treehouse in order to download course files.Sign up