In SQL we often want to update the data then we use the UPDATE statement, update can be updated according to your criteria, batch or single can be an instance.
Imagine that you have a MySQL table that has information for all employees in your company. The column in this table is called "seniority" and it has an integer value of how many months an employee has in your company. But unfortunately for you, your job is to update these numbers every month.
You may think you want to open your MySQL admin tool and edit each entry hand. This will take several hours. On the other hand, you can master MySQL and an automated script that you run every month to complete the task for you.
In this lesson you will learn how to replace the existing data, MySQL table fresh supply of the latest data to update the MySQL query.
For example, the MySQL update
We will again be with the data from previous examples. Sandy has just had a birthday, she is now 22 years old. Our task now is to update her age with MySQL commands like update, Setup, and location.
Update-Latest M ysql query for performance
Set-new values are placed in a subsequent set of tables
Where-the boundary and the effect of the line
<?php
Connect to MySQL
Get Sandy's record from the "example" table
$result = mysql_query ("UPDATE example SET age= ' WHERE age= ' 21 '")
Or Die (Mysql_error ());
$result = mysql_query ("SELECT * From Example WHERE age= ' 22")
Or Die (Mysql_error ());
Get the "Hopefully only" entry from
$row = Mysql_fetch_array ($result);
echo $row [' name ']. '-'. $row [' age ']. <br/> ";
?>
Output
22
It is important to note that this query will update all records of a 21-year-old new 22-Year-old. On a table Sandy is not the only entrance, which may become a problem, and more advanced solutions will be necessary www.111cn.net