MYSQL DELETE Query is used to delete existing records in a table.
- You can delete one or more field altogether.
- You can use any condition using the WHERE clause.
- You can delete the values in a single table at a time.
The WHERE clause is very useful when you want to delete the selected rows in a table.
MYSQL Syntax :
DELETE FROM table_name
MYSQL Query Example :
DELETE FROM tblstudent WHERE stud_id = 2;
Shell command script:
Also you can run delete query using mysql command Prompt.
[root@host]# mysql -u root -p
mysql> use aryatechno;
mysql> DELETE FROM tblstudent WHERE stud_id = 2;
Query OK, 1 row affected (0.003 sec)
PHP SCRIPT :
You can delete any records from table using php code as per as below.
$link= mysqli_connect($hostname, $username, $password);
$returnval = mysqli_query($link,"DELETE FROM tblstudent WHERE stud_id = 2");
echo "Data is deleted successfully.";
die('MySQL Error : ' . mysqli_error($link));