尝试在字符串字段上匹配 SQL 表更新
确实可以在更新查询方面使用一些帮助...(SQL Serer 2008 R2 Express) 我有两个表,tblJP
和 tblMaster
。
我只有一个在两个表之间匹配的字符串字段。
tblJP AND tblMaster
我需要使用 tblMaster.Long_text
更新 tblJP.LangString
tblJP.short_text = tblMaster.short_text AND tblMaster.Lang = 'jp'
任何帮助将不胜感激。我正在尝试各种逻辑和语法,从创建临时表到其他类型的连接,但都没有成功。
Could really use some help with an update query...(SQL Serer 2008 R2 Express)
I have two tables, tblJP
and tblMaster
.
I only have a string field that matches between the two tables.
tblJP AND tblMaster
I need to update tblJP.LangString
with tblMaster.Long_text
when
tblJP.short_text = tblMaster.short_text AND tblMaster.Lang = 'jp'
Any help would be greatly appreciated. I am spinning my wheels trying all sorts of logic and syntax from creating temp tables to other types of joins all with no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
INNER JOIN
进行简单更新就可以解决问题。警告:在没有首先针对开发服务器进行测试的情况下,切勿针对生产服务器运行更新语句 - 尤其是当其他人编写 SQL 时。
A simple update with an
INNER JOIN
should do the trick.WARNING: Never run an update statement against your production server without first testing it against a development server - especially when someone else wrote the SQL.
您还可以使用
MERGE
如果
JOIN
返回多行,您将收到错误提示The MERGE 语句尝试更新或删除同一行多次。
You could also use
MERGE
In the event that the
JOIN
returns multiple rows you will be alerted to the problem with an errorThe MERGE statement attempted to UPDATE or DELETE the same row more than once.