Syntax:
UPDATE TableName SET Column = NewValue WHERE Column = Value;
What does it do? The UPDATE statement will change the value of a field for one or multiple rows. The WHERE portion of the UPDATE is very important; it will only update the row(s) that match the WHERE constraint, without it all rows in the table will be affected.
Syntax - Multi Column Update:
A comma(,) must be placed in between each column that is being updated, except for the last column.
UPDATE TableName SET Column = NewValue, Column = NewValue WHERE Column = Value;
Syntax - Update using a join:
UPDATE TableName INNER JOIN TableName ON TableName.Column = TableName.Column SET TableName.Column = NewValue WHERE TableName.Column = Value;
Example:
UPDATE Customers SET LastName = 'Black' WHERE CustomerID = 1;
Before:
After:
Blue - Is used to identify reserved keywords/characters that are used by the SQL engine, i.e. SELECT, FROM, or WHERE.
Purple - Is used to identify portions of the SQL statement that are defined by the user, i.e. Column Names, Table Names, Inputed Values.