The DELETE order erases table columns from the predetermined table, and returns the amount erased. Access the amount erased with the ROW_COUNT() work. A WHERE condition indicates columns, and in its nonappearance, all lines are erased. A LIMIT proviso controls the quantity of columns erased.
In a DELETE proclamation for numerous columns, it erases just those lines fulfilling a condition; and LIMIT and WHERE provisos are not allowed. Erase proclamations permit erasing columns from tables in various information bases, however don't permit erasing from a table and afterward choosing from a similar table inside a subquery.
Audit the accompanying DELETE linguistic structure −
DELETE FROM table_name [WHERE …]
Execute a DELETE order from either the order brief or utilizing a PHP content.
The Command Prompt
At the order brief, basically utilize a standard order −
root@host# mysql –u root –p password;
Enter password:*******
mysql> use PRODUCTS;
Database changed
mysql> DELETE FROM products_tbl WHERE product_id=133;
mysql> SELECT * from products_tbl WHERE ID_number='133';
ERROR 1032 (HY000): Can't find record in 'products_tbl'
Utilize the mysql_query() work in DELETE order explanations −
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'DELETE FROM products_tbl WHERE product_id = 261';
mysql_select_db('PRODUCTS');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not delete data: ' . mysql_error());
}
echo "Deleted data successfully\n";
mysql_close($conn);
?>
On effective information erasure, you will see the accompanying yield −
mysql> Deleted data successfully
mysql> SELECT * from products_tbl WHERE ID_number='261';
ERROR 1032 (HY000): Can't find record in 'products_tbl'