更新tableB
中的id列,其中id爲tableA
,其中引用是縣。如果這些國家匹配,那麼這個ID應該填入tableB
。通過參照另一個表更新一個表的列的SQL查詢
請參考屏幕截圖以供參考。
表B: enter image description here
表A: enter image description here
我嘗試了查詢,但未能解決這個問題。
**update tableB set Id from tableB,tableA where tableA.countries=tableB.country;**
**update tableB set Id=(select id from tableA where countries=(select countries from tableA))**
其DBú[R使用? – Sachu
sql server manageemnt studio 2012 – anu
我的上帝,請在提交之前使用拼寫檢查器。 –