[英]MYSQL - join 2 tables, match multiple columns - update value from other table where multiple values match
[英]Update value where values from two columns match one column value?
我正在嘗試使用管理表中的 cityFull 值更新我的 mysql 表(cityTable),其中 cityCode 值與 cityTable 中的國家和城市匹配。
我相信這個說法應該奏效。 我唯一缺少的部分是要放入什么???? 對於城市代碼。 它有點復雜,因為它也有一個句點 (.)
UPDATE cityTable INNER JOIN administrativeTable ON (?????????? = administrativeTable.cityCode) SET cityTable.cityFull = administrativeTable.cityFull;
行政表
+----------+-----------+
| cityCode | cityFull |
+----------+-----------+
| AU.Melb | Melbourne |
| NZ.Auck | Auckland |
+----------+-----------+
城市表
+---------+------+-----------+
| country | city | cityFull |
+---------+------+-----------+
| AU | Melb | |
| NZ | Auck | |
+---------+------+-----------+
干杯!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.