Update Statement in SQL
The UPDATE statement in SQL is used to modify existing records in a table by changing one or more column values.
Key Points:
You specify the table to update.
Use the
SETclause to assign new values to columns.Optionally use a
WHEREclause to update only specific rows.Without
WHERE, all rows in the table are updated!
Syntax
UPDATE table_nameSET column1 = value1, column2 = value2, ...WHERE condition;WHEREcondition filters which rows to update.Multiple columns can be updated in one statement.
Example
Update a single row
UPDATE EmployeesSET Salary = 75000WHERE EmployeeID = 101;Update multiple columns and multiple rows
UPDATE EmployeesSET Salary = Salary * 1.1, -- 10% raise Title = 'Senior Developer'WHERE Department = 'IT';Important Notes
Always use
WHEREunless you want to update every row.You can use expressions and subqueries in
SETvalues.Some databases support
RETURNINGto show updated rows after execution.
If you want, I can help with examples for specific SQL databases or advanced UPDATE scenarios!