使用内连接更新? [英] Update with inner join?

查看:25
本文介绍了使用内连接更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个数据库:

DB1 and DB2

如何做类似的事情:

update myServer.DB1.dbo.hotels.Name = myServer.DB2.dbo.hotels.Name

join myServer.DB2.dbo.hotels on myServer.DB2.dbo.hotels.Code=  myServer.DB1.dbo.hotels.Code
where myServer.DB2.dbo.hotels.CountryCoe !=  myServer.DB1.dbo.hotels.CountryCode

推荐答案

UPDATE  h1
SET     h1.name = h2.name
FROM    myServer.DB1.dbo.hotels h1
JOIN    myServer.DB2.dbo.hotels h2
ON      h2.Code = h1.Code
WHERE   h1.CountryCode <> h2.CountryCode

这篇关于使用内连接更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆