gpt4 book ai didi

mysql - 删除 2 个表的查询不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 11:13:30 25 4
gpt4 key购买 nike

public function deleteCustomerFunc($CustID)
{
$sql = "DELETE customer, cargo
FROM customer AS cust, cargo AS car
WHERE cust.CustID = car.CustID
AND CustID='$CustID'";

$result = mysql_query($sql);
return $result;
}

我有 2 个表:

1)客户-CustID-主键2)Cargo-id-primary key,CustID=Foreign key

最佳答案

特定的错误消息会有所帮助。但是,我最初的猜测是您的 AND 子句不明确 - CustID 可以指 cust 或 car 表。虽然在这种情况下使用哪一个并不重要,但解释器并不知道这一点,您需要指定其中一个。

public function deleteCustomerFunc($CustID)
{
$sql = "DELETE customer, cargo
FROM customer AS cust, cargo AS car
WHERE cust.CustID = car.CustID
AND cust.CustID='$CustID'";

$result = mysql_query($sql);
return $result;
}

关于mysql - 删除 2 个表的查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6893436/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com