请帮我解决此错误:
注意:错误:您的SQL语法中有错误;检查与您的MariaDB服务器版本对应的手册,以便使用接近' c FROM oc_coupon c LEFT JOIN oc_cheaper_order_coupons coc使用(coupon_id)WHER'在第1行 错误号码:1064
DELETE oc_coupon c FROM oc_coupon c LEFT JOIN oc_cheaper_order_coupons coc using(coupon_id) WHERE coc.order_id = '26' in /home/blablabl/public_html/shop/system/database/mysql.php on line 50
代码是:
class ModelSaleCheaper extends Model {
public function deleteOrder($order_id) {
$this->db->query("DELETE " . DB_PREFIX . "coupon c FROM " . DB_PREFIX . "coupon c LEFT JOIN " . DB_PREFIX . "cheaper_order_coupons coc using(coupon_id) WHERE coc.order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE " . DB_PREFIX . "coupon_product cp FROM " . DB_PREFIX . "coupon_product cp LEFT JOIN " . DB_PREFIX . "cheaper_order_coupons coc using(coupon_id) WHERE coc.order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "cheaper_order_coupons WHERE order_id = '" . (int)$order_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "cheaper_order WHERE order_id = '" . (int)$order_id . "'");
答案 0 :(得分:0)
有效查询可能如下所示:
DELETE c -- assuming you only want to DELETE from coupon
FROM " . DB_PREFIX . "coupon c
JOIN " . DB_PREFIX . "cheaper_order_coupons coc USING(coupon_id)
WHERE coc.order_id = $order_id;
另一个例子......
DELETE cp
FROM oc_coupon_product cp
JOIN oc_cheaper_order_coupons coc USING(coupon_id)
WHERE coc.order_id = 26