DELETE keyword is used basically to delete 1 or more than one records from the database table.even if we delete each and every row of a table then also the schema of the table remain un deleted. It,s necessary to use where clause in delete query, otherwise all the records will be deleted.Syntax
DELETE FROM table_name WHERE some_column = some_value
Note : Notice the WHERE clause in the DELETE syntax is must otherwise all records will be deleted! Eg 1 Previous records in empInfo table are:
This example deleted one row from "empInfo" table
<?php //connect database $con=mysqli_connect("localhost","root","","Employee") or die(mysqli_error()); //update values of empInfo table $data="delete from empInfo WHERE firstname.lastname@example.org'"; mysqli_query($con,$data); ?>
In the above example , empInfo table has 3 records of devesh,deepak, and ravi. we need to delete a record from this table. The record of devesh here is to be deleted. here first we create connection with the database,then database is selected using mysql_select_db(), then delete query is passed to the mysql_query and the table row is deleted.