Unlike the INSERT command in SQL, the UPDATE command is used to modify existing rows in a table.
Syntax of the UPDATE Command in SQL
Modify table_name
Assign value1 to column_name1,
value2 to column_name2, and so on
[WHERE condition]
In which:
table_name: the table name that needs to be updated.
column_name1, column_name2 .. : the columns to be changed.
value1, value2 ... : are the new values.
Note: In the structure of the UPDATE command in SQL, the WHERE clause specifies the affected rows. If you don't add a WHERE clause, the values of the columns for all rows will be affected.
Example of UPDATE command in SQL
To update the position of employees, the SQL UPDATE query looks like this:
UPDATE employees
Assign 'Mysore' to position
WHERE id = 101;
To adjust the salary of all employees, the query takes the form:
UPDATE employees
Adjust salary to increase by 20%;
Above, Mytour just introduced you to the SQL UPDATE command. If you have any questions or need clarification, please feel free to leave your comments below the article. Don't forget to explore some articles on commands like CREATE, DELETE, JOINS command in SQL,... on Mytour.
