Update syntax
| The code is as follows |
Copy Code |
UPDATE [low_priority] [IGNORE] Tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE Where_definition] [Order BY ...] [LIMIT Row_count] |
Instance
| The code is as follows |
Copy Code |
CREATE table links (name varchar (255) NOT null default ", URL varchar (255) NOT NULL default"); |
Let's just insert some data.
| The code is as follows |
Copy Code |
INSERT into the users (name, age) VALUES (' Yao Ming ', 25), (' Bill Gates ', 50), (' Martians ', 600); |
Update All records
| The code is as follows |
Copy Code |
Update links set url= ' http://www.111cn.net '; |
The above update is the entire data table URL value is clay written to http://www.111cn.net, so it is certainly not suitable for the current generation of data development,
| The code is as follows |
Copy Code |
Update user Set Password = Password (' 123456 ') where user = ' root ';
|
The above can be updated with some data according to the condition, so that we can update it according to the next where condition.
Here's a way to share a PHP to update a specified record in the MySQL database
| code is as follows |
copy code |
| <?php $con = mysql_connect ("localhost", "Peter", "abc123"); if (! $con) { die (' could not connect: '. Mysql_error ()); } mysql_select_db ("my_db", $con); mysql_query ("UPDATE Persons SET age = ' = ' WHERE FirstName = ' Peter ' and LastName = ' Griffin '"); Mysql_close ( $con); ? |