PHP MySQL Data Deletion Delete
The DELETE statement is used to record the deletion table.
Delete data from a database
The deletion of the declaration is used to delete records from the database table.
Grammar
DELETE from table_name WHERE some_column = some_value
Note: Note the syntax that is removed in the WHERE clause. The record or record specified in the WHERE clause should be deleted.
If you ignore the WHERE clause, all records will be deleted!
To learn more about SQL, please visit our SQL Tutorial.
In order for PHP to execute the above statement, we must use the mysql_query () function. This feature is used to send a MySQL connection to a query or command.
For example
Look at the "person" table below:
FirstName |
LastName |
| Age
Peter |
Griffin |
35 |
Glenn |
Quagmire |
33 |
The following example deletes all records in the "person" peter= ' Griffin:
<?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);
? >
After executing the above code,
FirstName |
LastName |
| Age
Glenn |
Quagmire |
33 |
Reprint please indicate from: www.111cn.net/database/database.html