SQL 查询——从同一个表中的 1 条记录更新多条记录
我们有一张位置表。 同一个地方可能会在我们的表中出现多次(糟糕的设计,不是我们的选择)。 我们派人仔细检查并找到每个地方的地址。 他们只更新了每个地点的众多实例之一。
这是一个不起作用的查询,但我认为显示了我正在尝试做的事情。
update places set address1 = places2.address1
inner join places places2 ON places.placename = places2.placename
where (places2.address1 <> '' AND places2.address1 is not null)
有人想推动我朝正确的方向前进吗?
We've got a table of places. The same place may occur multiple times in our table (bad design, not our choice). We had someone go through and find addresses for each of these places. They only updated one of the many instances of each place.
Here is a query that does NOT work, but I think shows what I am trying to do.
update places set address1 = places2.address1
inner join places places2 ON places.placename = places2.placename
where (places2.address1 <> '' AND places2.address1 is not null)
Anyone want to give me a nudge in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)