PHP Programing language

PHP MySQL Delete
Previous Home Next

In MySQL table the maintenance is a very common task, from time to time, if you want to update or delete some items in your database table .when in company profile database holds employees summary then if any employee leaves a company, or you're trying to destroy your records before the federalizes come.


The DELETE is much easier for the UPDATE Query. so, you need to choose a table, and tell MySQL to perform the deletion, and provide the requirements that a record must have for it to be deleted.Say we want to delete the youngest employee from our created table, which table before created, then he has to go back to school. This is how we do it.

PHP & MySQL Code:
// Connect to MySQL
// Delete Amit from the "example" MySQL table
mysql_query("DELETE FROM example WHERE age='22'") 
or die(mysql_error());  s

It is important to note that this query would have deleted ALL records that had an age of 22. Since Amit was the only 15 year old this was not a problem.


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 even thinking about using them on your table. As long as you take caution when using this powerful query you should not run into any problems.

Previous Home Next