简体   繁体   中英

Delete only certain things from database

I got this php script from w3schools and I was wondering if its possible to only delete the last name and leave the first name which is peter?

<?php
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno())
{
 echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

 mysqli_query($con,"DELETE FROM Persons WHERE LastName='Griffin'");

mysqli_close($con);
?> 

source: http://www.w3schools.com/php/php_mysql_delete.asp

Yes, just do

UPDATE Persons
    set LastName = ''
WHERE
    id = ?

or alternatively set LastName = NULL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM