此更新查询似乎可以在MySQL WorkBench内运行,但是当将其应用于我的php应用程序时则不起作用... $TotalSeats$PerfID参数都已经过测试,它们会输出所需的数字。

这是一个较小的语法错误,还是我在这里错过了一个窍门?

$deductSeats = "UPDATE perf SET Seats=(SELECT SUM(Seats -'$TotalSeats')) WHERE PerfID = '$PerfID'";
            if (mysqli_query($conn,$deductSeats))
            {
                echo 'Query Worked!<br>';
            }
            else
            {
                echo 'Query Didnt Work<br>';
            }





$deductSeats = "deductSeats(`$TotalSeats`,`$PerfID`)";

最佳答案

你可以试试 :

$deductSeats = "UPDATE perf SET `Seats` = `Seats` - ".$TotalSeats." WHERE PerfID = ".$PerfID;

    if (mysqli_query($conn,$deductSeats)) {
        echo 'Query Worked!<br>';
    } else {
        echo 'Query Didnt Work<br>';
    }

07-28 07:49