仅从数据库中删除某些内容

时间:2013-11-26 22:09:17

标签: php sql-delete

我从w3schools获得了这个PHP脚本,我想知道是否可能只删除姓氏并留下名字是彼得?

<?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);
?> 

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

1 个答案:

答案 0 :(得分:1)

是的,只是做

UPDATE Persons
    set LastName = ''
WHERE
    id = ?

或者设置LastName = NULL