0

Hello boys and girls :)

I have that query:

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

So i want to update custome.status to 0 I tried with that query but "0 rows affected":

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

I have about 200 ppl with address.country_id = 176 !

Any ideas, thank u !

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
MorganFreeFarm
  • 3,811
  • 8
  • 23
  • 46

1 Answers1

1

You can try a different approach with EXISTS instead of JOIN

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

Can't recall, but is it possible, that MySQL won't report change for those records where status is already equals to 0?

Pred
  • 8,789
  • 3
  • 26
  • 46