亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

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