- Update query is used to update entries in table.
- It will update the entries of specified columns in all rows of the table.
- It will update the entries of specified columns in the rows for which the condition of WHERE clause is satisfied.
- Note: Where Clause is used to specify some conditions in a query. After using WHERE clause, only those records will be retrieved which will fulfil the condition.
We have following table with us-
- Now we have to update data in the above table using following code:
$query=”UPDATE employee SET name=’Tom’,salary=’50000′ WHERE id=’1′”;
After running the program, the table will appear as following:
- Above program updates two columns ‘name’ and ‘salary’. But the condition is that the id must be ‘1’. Therefore the changes will occur only in the row which contains ‘1’ as the value of ‘id’ column.