0
The case:

我有一个包含以下详细信息的表格(300 行):

     id     | locality| postcode| declat  | declong | alias             |
    ---------------------------------------------------------------------    
     13     |         |         |         |         | bla bla wimar bla |
     14     |         |         |         |         | bla bla bla bla   |
     15     |         |         |         |         | bla bla bla arafo |

和其他包含此数据的邮政编码表(900 行):

    locality| postcode | lat        | long
    ---------------------------------------------    
      cande | 504      | 37.9418594 | -0.7795244
      arafo | 501      | 38.9418594 | -0.7795255  
      wimar | 500      | 39.9418594 | -0.7795277

我需要像这样更新表格不动产的行:

      id     | locality| postcode| declat     | declong   | alias             |
    ---------------------------------------------------------------------------    
      13     |  wimar  | 500     | 39.9418594 |-0.7795277 | bla bla wimar bla |
      14     |         |         |            |           | bla bla bla bla   |
      15     |  arafo  | 501     | 38.9418594 |-0.7795255 | bla bla bla arafo |

谢谢你。

4

1 回答 1

0

根据您的 rdbms,如果这只是一个关闭,您可以尝试这样的事情:

UPDATE realty
  SET locality = p.locality
     ,postcode = p.postcode
     ,declat =  p.declat
     ,declong = p.declong
  FROM postcodes p
  WHERE alias LIKE '%' || p.locality || '%'

不过,需要注意一堆东西(扫描、重复匹配等)

于 2012-05-20T00:57:57.607 回答