0
我有3個表如何更新通過連接兩個表在MySQL
- iata_en表3列(CITY_NAME,COUNTRY_NAME,iata_code)
- d_cities表3列(CITY_NAME,COUNTRY_ID,iata_code)
- d_country表2的列(COUNTRY_ID,COUNTRY_NAME)
我想iata_code柱從表複製到iata_en表d_citites其中(iata_en.cityname = d_cities.cityname)和iata_en.countryname = d_cities.country_nam e)
- 所以我加入了d_cities和d_country與外鍵得到 country_name。
我寫這篇文章的代碼,但它不工作
UPDATE d_cities
SET iata_code=iata_en.iata_code
FROM iata_en,d_cities as ci
INNER JOIN d_country as co
ON ci.CountryID=co.CountryID
WHERE iata_en.city_name=ci.city
AND iata_en.country_name=co.country
沒有什麼不是我want..i要確保國家名稱和城市名稱等於其在傳輸之前iata_en城市和國家名稱iata_code..so我想加入副本之前d_cities和d_country數據 – user1673473
編輯查詢。 –