Many times we enter wrong information or we want to remove any record in database and we want to delete this wrong information then we can use PHP statement DELETE query for delete this information from database. In the DELETE statement we have to define column name for delete information in database otherwise all record will delete from database by using PHP script.
In the PHP tutorial we will discuss about MySQL DELETE statement. This useful feature in MySQL with PHP script because it can delete record without affecting other record. If we want to delete only one record in database then we should assign WHERE Clause with particular column name in PHP Script. Its very important to if we will not define column name with WHERE Clause then we will loss all record from database because DELETE query will delete all record in database and we cannot recover all record after delete in database by PHP script.

In the PHP tutorial we will discuss about MySQL DELETE statement. This useful feature in MySQL with PHP script because it can delete record without affecting other record. If we want to delete only one record in database then we should assign WHERE Clause with particular column name in PHP Script. Its very important to if we will not define column name with WHERE Clause then we will loss all record from database because DELETE query will delete all record in database and we cannot recover all record after delete in database by PHP script.
Syntax:
DELETE FROM table_name WHERE some_column= some_value
Example:
<?php
$con= mysql_connect("localhost","PeterJohn","abc124");
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);
?>
Comments
Post a Comment