Learn MySQL for Developing Web Application

Learn to build web applications with PHP and MySQL, Start your own blog, e-commerce site. In this tutorial you will learn queries of MySQL and MySQLi.

SQL UPDATE Query


The SQL commands (UPDATE and DELETE) are used to modify the data that is already in the database. The SQL DELETE command uses a WHERE clause.

SQL UPDATE statement is used to change the data of the records held by tables. Which rows is to be update, it is decided by a condition. To specify condition, we use WHERE clause.

Once there is some data in the table, it may be required to modify the data. To do so, the SQL UPDATE command can be used. It changes the records in tables.

The SQL UPDATE command changes the data which already exists in the table. Usually, it is needed to make a conditional UPDATE in order to specify which row(s) are going to be updated.

The WHERE clause is used to make the update restricted and the updating can happen only on the specified rows.

Without using any WHERE clause (or without making any restriction) the SQL UPDATE command can change all the records for the specific columns of a table.


Syntax:

UPDATE < table name > SET<column1>=<value1>,<column2>=<value2>,.....
WHERE <condition>;

Parameters:

Name Description
table_name Name of the table to be updated.
column1,column2 Name of the columns of the table.
value1,value2 New values.
condition Condition(s) using various functions and operators.