Home >Backend Development >PHP Problem >What is the php sql delete statement?
php sql delete statement is "DELETE FROM", which is used to delete rows from the database table. Its syntax is "DELETE FROM table_name WHERE column_name = some_value".
Recommended: "PHP Video Tutorial"
PHP MySQL Delete From
DELETE FROM statement is used to delete rows from a database table.
Delete data in the database
The DELETE FROM statement is used to delete records from the database table.
Syntax
DELETE FROM table_name WHERE column_name = some_value
Note: SQL is not case sensitive. DELETE FROM is equivalent to delete from.
In order for PHP to execute the above statement, we must use the mysql_query( function. This function is used to send queries and commands to the SQL connection.
The following example deletes all LastNames in the "Persons" table ='Griffin' record:
<?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("DELETE FROM Persons WHERE LastName='Griffin'"); mysql_close($con); ?>
The above is the detailed content of What is the php sql delete statement?. For more information, please follow other related articles on the PHP Chinese website!