【问题标题】:Pattern matching sql algorithm模式匹配sql算法
【发布时间】:2012-07-27 15:32:24
【问题描述】:
Table 1
Account ID   Account name 
Missing      Agreete NV.


Table 2 
Account ID   Account name 
XXX4546778   Agreete

我必须根据两个表中帐户名称的最佳匹配来填充表 1 中的所有帐户 ID。

我想过像 patindex 和 soundex。

考虑一下,我在考虑比较完整字符串,如果不匹配则比较完整字符串 -1 ,如果不匹配则比较完整字符串 -2 直到匹配。

但是,一定有人想出了模式匹配 sql 算法,它会以低错误率做到这一点。有什么想法吗?

【问题讨论】:

  • 其中一个不错的让业主赚了很多钱:)
  • james,这是一个很好的问题,我渴望看到可能的解决方案

标签: sql sql-server


【解决方案1】:

也许我错过了你的问题的重点,但在我看来你和你说的完全匹配

update t1
set [account id] = t2.[account id]
from table1 t1
inner join table2 t2 on t1.[account name] = t2.[account name]
where t1.[account id] = 'missing'

你有部分匹配

update t1
set [account id] = t2.[account id]
from table1 t1
inner join table2 t2 on t1.[account name] like t2.[account name] + '%'
where t1.[account id] = 'missing'

按此顺序运行...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-05
    • 1970-01-01
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    • 2018-05-29
    • 1970-01-01
    相关资源
    最近更新 更多