In SQL, we often want to update data, so we will use the update statement. update can be updated according to your conditions, and can be used in batches or in a single instance.
In SQL, we often want to update data so we will use the update statement,UpdateYou can update the instance according to your conditions, batch or single instance.
Imagine that you have a MySQL table and all employees with information are in your company. The column in this table is called "qualifications" and it has an integer value for how many months the employee has been in your company. But unfortunately, your job is to update these numbers every month.
You may think that you want to open your MySQL management tool and edit each entry. This will take several hours. On the other hand, you can master MySQL and an automated script. You need to complete the task every month.
In this lesson, you will learn how to replace existing data and update MySQL queries with the latest data that MySQL tables provide.
For example, MySQL update
We will again associate with the data from the previous example. Sha has just had a birthday. She is now 22 years old. Our current task is to update her age using MySQL commands like update, set, and location.
Update-latest performance M ySQL Query
Set-new values are placed in the Post-sequel to the table
Where-influence of line over line
<? Php
// Connect to MySQL
// Get Sandy's record from the "example" table
$ Result = mysql_query ("UPDATE example SET age = '22' WHERE age = '21 '")
Or die (mysql_error ());
$ Result = mysql_query ("SELECT * FROM example WHERE age = '22 '")
Or die (mysql_error ());
// Get the first (and hopefully only) entry from the result
$ Row = mysql_fetch_array ($ result );
Echo $ row ['name']. "-". $ row ['age']. "<br/> ";
?>
Output
22
Now it is important to note that this query will update all records for a 21-year-old New 22-year-old. Sandground on a table is not the only portal, which may become a problem, and more advanced solutions will be necessary www.111cn.cn