无法删除任何元组

时间:2018-03-30 10:39:18

标签: php mysql

请指出对代码的修改,以便根据查询删除部分/所有行

<?php 

require_once ('config.php');

$mid = $_POST['mid'];
$pid = $_POST['pid'];

$sql = "DELETE * FROM assignment WHERE project_id = '$pid', member_id = '$mid'";

$retval = mysqli_query($connection, $sql);

    if($retval)
    {
        die('Could not delete data: ' . mysqli_error());
    }            

echo "Deleted data successfully";

mysqli_close($connection);

?>

2 个答案:

答案 0 :(得分:0)

删除,并使用and

$sql = "DELETE * FROM assignment WHERE project_id = '$pid' and member_id = '$mid'";

答案 1 :(得分:0)

WHERE子句与AND逻辑运算符一起使用时,仅在满足指定的所有过滤条件时执行。

$sql = "DELETE * FROM assignment WHERE project_id = '$pid' AND member_id = '$mid'";