0

你好男孩和女孩:)

我有这个查询:

SELECT * FROM customer
INNER JOIN address ON customer.customer_id = address.customer_id
WHERE address.country_id = 176

所以我想更新custome.status到 0 我尝试使用该查询但“0 行受影响”:

UPDATE customer
INNER JOIN address ON customer.customer_id = address.customer_id
SET customer.status = 0
WHERE address.country_id = 176

我有大约 200 个地址.country_id = 176 的人!

任何想法,谢谢你!

4

1 回答 1

1

您可以尝试使用 EXISTS 而不是 JOIN 的不同方法

UPDATE
  customer
SET
  status = 0
WHERE
  EXISTS (
    SELECT *
    FROM address A
    WHERE customer.customer_id = A.customer_id AND country_id = 176
  )

不记得了,但有可能,MySQL 不会报告那些状态已经等于 0 的记录的更改吗?

于 2017-11-24T13:52:18.630 回答