用另一个表的引用更新一个表的列的SQL查询
使用引用为县的用另一个表的引用更新一个表的列的SQL查询,sql,sql-server-2012,Sql,Sql Server 2012,使用引用为县的表A中的id更新表B中的id列。如果国家/地区匹配,则应将id填入表B 请参阅屏幕截图以供参考 表B: 表a: 我试过这些问题,但解决不了 **update tableB set Id from tableB,tableA where tableA.countries=tableB.country;** **update tableB set Id=(select id from tableA where countries=(select countries fro
表A
中的id更新表B
中的id列。如果国家/地区匹配,则应将id填入表B
请参阅屏幕截图以供参考
表B:
表a:
我试过这些问题,但解决不了
**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 ))**
你可以试试这个查询
UPDATE
tableB
SET
tableB.ID = A.ID
FROM
tableB B
INNER JOIN
tableA A
ON
B.country = A.countries
你可以试试这个查询
UPDATE
tableB
SET
tableB.ID = A.ID
FROM
tableB B
INNER JOIN
tableA A
ON
B.country = A.countries
sql server ManageMnt studio 2012我的上帝,请在点击提交之前使用拼写检查程序。sql server ManageMnt studio 2012我的上帝,请在点击提交之前使用拼写检查程序。