Updating Specific Rows4:42 with Andrew Chalkley
It's more useful to update specific rows. Like with SELECT statements, you can use conditions to target specific rows.
An update statement for specific rows:
UPDATE <table> SET <column> = <value> WHERE <condition>;
UPDATE users SET password = "thisisabadidea" WHERE id = 3; UPDATE blog_posts SET view_count = 1923 WHERE title = "SQL is Awesome";
Update multiple columns for specific rows:
UPDATE <table> SET <column 1> = <value 1>, <column 2> = <value 2> WHERE <condition>;
UPDATE users SET entry_url = "/home", last_login = "2016-01-05" WHERE id = 329; UPDATE products SET status = "SOLD OUT", availability = "In 1 Week" WHERE stock_count = 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