我有两张table directory_country
|country_id |iso2_code |iso3_code |AD |AD |AND |AE |AE |ARE |AF |AF |AFG |AG |AG |ATG ...
customer_address_entity_varchar
```
|value_id |entity_type_id |attribute_id |entity_id |value
|1 |2 |19 |1 |asdad
|2 |2 |20 |1 |Petya
|3 |2 |21 |1 |NULL
|4 |2 |22 |1 |Vasin
|5 |2 |23 |1 |asdasdasd
|6 |2 |24 |1 |asdasd
|7 |2 |26 |1 |KKK
|8 |2 |27 |1 |AFG
|9 |2 |28 |1 |American Samoa
|18 |2 |27 |2 |ARE
|35 |2 |28 |3 |Georgia
|36 |2 |30 |3 |123
|37 |2 |27 |3 |US
|38 |2 |31 |3 |133
我需要换衣服 `customer_address_entity_varchar.value` 到相应的 `directory_country.country_id` 哪里 `customer_address_entity_varchar.value` = `directory_country.iso3_code` 在哪里 `customer_address_entity_varchar.attribute_id` = 27. 这意味着要将are改为ae,afg改为af中的 `customer_address_entity_varchar` .
我研究过mysql更新教程和构建查询,但它不起作用,也没有显示错误。查询
UPDATE customer_address_entity_varchar
INNER JOIN directory_country
ON customer_address_entity_varchar.value = directory_country.iso3_code
SET value
= directory_country.country_id
WHERE attribute_id
= 27;
感谢您的解决方案。
1条答案
按热度按时间bis0qfac1#
phpmyadmin中出现了一些问题,查询是正确的。我在这里留下正确答案。愿它能帮助某人。
带说明的教程:http://www.mysqltutorial.org/mysql-update-join/