Now that you've mastered INSERTs, let's modify existing data! UPDATE statements change values in rows that already exist in your table.
Remember our SQL engine pipeline? UPDATE goes through the same parsing, planning, optimization, and execution stages.
Engagement Message
Which stage actually writes the new data to disk?
The basic UPDATE pattern is: UPDATE table SET column = new_value WHERE condition
. The WHERE clause is crucial—it determines which rows get changed.
Without WHERE, you'd update EVERY row in the table!
Engagement Message
What unintended consequences might occur if every customer record got updated?
Let's see UPDATE in action:
This changes John's age to 26, but leaves everyone else unchanged.
Engagement Message
Name one other piece of information you might want to update for John?
The WHERE clause acts like a filter—only rows matching the condition get updated. Think of it as highlighting specific rows before making changes.
This targets only the laptop product row.
Engagement Message
What changes, if any, occur to non-laptop products?
You can update multiple columns at once by separating them with commas:
Both John's age and job change in a single statement.
Engagement Message
Why might updating multiple columns together be better than separate UPDATEs?
