MySQL Delete

From time to time, you may even need to delete items from your database. The DELETE query is very similar to the UPDATE Query. We need to choose a table, tell MySQL to perform the deletion, and provide the requirements that a record must have for it to be deleted.
The following example deletes all the records in the "Persons" table where LastName='Griffin':
1
2
3
4
5
6
7
8
9
10
11
12
13
<?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);
?>
Before performing a large delete on a database, be sure to back up the table/database in case your script takes off a little more than desired. Test your delete queries before using them on your table. As long as you take caution when using this powerful query you should not run into any problems.

MySQL Order By
MySQL Update
XML Expat Parser
XML DOM