• Have Any Question?
  • contact@eitworld.com

MySQLi Delete Data





  • Delete query is used to delete desired rows from table.

Syntax

Syntax1

    • To delete all the rows from table:
DELETE FROM tableName;
  • It will delete all the rows that satisfy the condition:

Syntax2

DELETE FROM tableName WHERE conditions;

Example

We have following table with us-

id name salary contact
1 John 25000 7777777
2 Peter 40000 9999999
  • Now we have to delete data from the above table using following code:

<!DOCTYPE html>

<html>

<body>

<?php

$connect=mysqli_connect("localhost","root","","firstdb");

$query="DELETE FROM employee WHERE name='peter'";

$result=mysqli_query($connect,$query);

?>

</body>

</html>

Output

After running the program, the table will appear as following:

id name salary contact
1 John 25000 7777777
  • Above program will delete the row/rows in which have ‘peter’ as the value of column ‘name’.


Real Time Web Analytics