cuốn sách gpt4 ai đã làm

带有 WHERE 子句和 INNER JOIN 的 MySQL 更新查询不起作用

In lại Tác giả: Hồ Xil 更新时间:2023-11-01 07:20:14 25 4
mua khóa gpt4 Nike

我的更新查询似乎无法进行下一步。我能够成功查看与选择相关的列没问题:

SELECT sales_flat_order_grid.entity_id,sales_flat_order_grid.increment_id,sales_flat_order.coupon_code
FROM sales_flat_order_grid
INNER JOIN sales_flat_order ON sales_flat_order_grid.entity_id = sales_flat_order.entity_id
WHERE sales_flat_order_grid.increment_id = "12345678";

这显示了 3 列,所有列都与正确的 increment_id 相关。

下一步是更新 sales_flat_order.coupon_code 字段。这是我的尝试:

UPDATE sales_flat_order 
INNER JOIN sales_flat_order ON sales_flat_order_grid.entity_id = sales_flat_order.entity_id
WHERE sales_flat_order_grid.increment_id = "12345678"
SET coupon_code = "newcoupon";

但我不断收到 Not unique table/alias: 'sales_flat_order' 错误消息。有人能指出我正确的方向吗?

câu trả lời hay nhất

查询应该如下所示,您已经加入了同一个表,因此存在唯一别名的问题。我添加了表别名以提高可读性。

CẬP NHẬT 
sales_flat_order sfo
INNER JOIN sales_flat_order_grid sfog
ON sfog.entity_id = sfo.entity_id
SET sfo.coupon_code = "newcoupon"
WHERE sfog.increment_id = "12345678" ;

关于带有 WHERE 子句和 INNER JOIN 的 MySQL 更新查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26018065/

25 4 0

我有使用引导类并动态添加 带有引导类和 clearfix 的元素 var li = $("").addClass("list-group-item clearfix"); var div = $(

  • java - 创建名称为 'Test_flow' : Cannot create inner bean '(inner bean) 的 bean 时出错

    我已经为 Test_flow 创建了简单的测试套件,但是当我尝试运行该流程时出现错误。 java.lang.RuntimeException: org.mule.api.config.Configur

  • Hồ Xil
    Hồ sơ

    Tôi là một lập trình viên xuất sắc, rất giỏi!

    Nhận phiếu giảm giá taxi Didi miễn phí
    Phiếu giảm giá taxi Didi
    Chứng chỉ ICP Bắc Kinh số 000000
    Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
    Xem sitemap của VNExpress