国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP MySQL Delete

DELETE statement is used to delete rows from a database table.

Syntax

DELETE FROM table_name

WHERE some_column = some_value

Note: Please pay attention to the WHERE clause in the DELETE syntax. The WHERE clause specifies which records need to be deleted. If you want to omit the WHERE clause, all records will be deleted!

To learn more about SQL, please visit our SQL tutorial.


Example description

Let’s take a look at the data in our Myguests first:

6.png

Let’s delete the firstname=’Mary’ data

<?php
 header("Content-type:text/html;charset=utf-8");    //設(shè)置編碼
 $con=mysqli_connect("localhost","root","root","test");
 // 檢測連接
 if (mysqli_connect_errno())
 {
     echo "連接失敗: " . mysqli_connect_error();
 }
 
 mysqli_query($con,"DELETE FROM Myguests WHERE firstname='Mary'");
 
 mysqli_close($con);
 ?>

Run the program:

2.png

Let’s look at the data in the table again

Has been deleted successfully

【Remember】

1. Be sure to remember to add the where condition when deleting, otherwise the entire table will be cleared record of.

2. Be sure to back up, back up, back up before deleting important data.


Continuing Learning
||
<?php header("Content-type:text/html;charset=utf-8"); //設(shè)置編碼 $con=mysqli_connect("localhost","root","root","test"); // 檢測連接 if (mysqli_connect_errno()) { echo "連接失敗: " . mysqli_connect_error(); } mysqli_query($con,"DELETE FROM Myguests WHERE firstname='Mary'"); mysqli_close($con); ?>
submitReset Code