【问题标题】:Cope extra value from a column of a row to same column of another row in the same table将行的一列的额外值处理到同一个表中另一行的同一列
【发布时间】:2022-06-12 21:47:52
【问题描述】:

我有一个名为 Address 的表,其中包含来自两个来源的数千行,例如:X 和 Y。我想复制 Postcode 的额外值,即从 Source Y 到 Source X 的 6 字符邮政编码。我是能够通过插入条件来做到这一点,但这不是最好的方法,因为它有数千行并且两个源的 StreetName 是不同的,即使它是同一条街道。下面是表格的样子。

Source City StreetName StreetNo Postcode
X Pilar Luis Pasteur 11 B123,123
X Pilar Luis Pasteur 12 B456,456
X Pilar Luis Pasteur 13 B789,789
Y Pilar Calle Luis Pasteur 11 B123AB, B123,123
Y Pilar Calle Luis Pasteur 12 B456CD, B456,456
Y Pilar Calle Luis Pasteur 13 B789EF, B789,789

有没有办法自己加入一个表来实现我想要的?我的想法是通过 StreetNo 加入它。

【问题讨论】:

  • the StreetName of the two sources are different eventho it is the same street ... 你需要告诉我们如何判断它是同一条街道的逻辑。否则,与邮政编码不匹配相比,您的数据存在更大的问题。
  • 街道由 streetno 和 postcode 子集的匹配值标识。如果这些列的值匹配,则意味着它是同一条街道。以前我尝试通过使用“where”条件来为每个来源声明街道名称来加入它,但当然这不是这样做的方法:(

标签: mysql sql


猜你喜欢
  • 2023-01-11
  • 2016-05-18
  • 2012-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-21
  • 1970-01-01
相关资源
最近更新 更多