Mysql update database Field tutorial syntax UPDATEtable_nameSETcolumn_namenew_valueWHEREcolumn_namesome_value Note: SQL is case insensitive. UPDATE is equivalent to update. In order for PHP to execute the preceding statement, we must use mysql_query (function. This function is used to connect SQL statements.
Mysql UPDATE database Field tutorial syntax UPDATE table_name SET column_name = new_value WHERE column_name = some_value Note: SQL is case insensitive. UPDATE is equivalent to update. In order for PHP to execute the preceding statement, we must use mysql_query (function. This function is used to connect SQL statements.
How to update database fields in mysql
Syntax
UPDATE table_name SET column_name = new_value WHERE column_name = some_value
Note: SQL is case insensitive. UPDATE is equivalent to update.
In order for PHP to execute the preceding statement, we must use mysql_query (function. This function is used to send queries and commands to SQL connections.
Example
Earlier, we created a table named "Person" in this tutorial. It looks like this:
FirstName LastName Age Peter Griffin in 35 Glenn Quagmire 33
The following example updates some data in the "Person" table:
$ Con = mysql_connect ("localhost", "peter", "abc123 ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}
Mysql_select_db ("my_db", $ con );
Mysql_query ("UPDATE Person SET Age = '36'
WHERE FirstName = 'Peter 'AND LastName = 'grigin '");
Mysql_close ($ con );
?>
After this update, the "Person" table is as follows:
FirstName LastName Age
Peter Griffin 36
Glenn Quagmire 33
Note: More exciting articles, please pay attention to SanlianProgramming TutorialTopic.