SQL TutorialLesson 12Free preview
SQL Update
This lesson is part of SQL · All levels
Summary
UPDATE is used to change the value of an existing row in a table. Always use the WHERE clause so that only the target line changes; without WHERE, the entire line in the table is updated. You can change several columns at once by using a comma to separate them.
Key points
- Structure: UPDATE the table SET column = the WHERE value of the condition;
- Without WHERE, all the lines on the table would change.
- Several columns are changed at once: SET column1 = v1, column2 = v2.
- The new value can be an expression, for example price = price * 1.1.
- You'd better check with the same SELECT before running the big update.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.