使用T-SQL进行模糊匹配

使用T-SQL进行模糊匹配

我有一个表的人与personaldata等。有很多专栏,但这里曾经感兴趣的是:addressindex,lastname以及firstname在addressindex公寓门口钻一个独特的地址。因此,如果我“喜欢下面”两个人和lastname一个人firstnames相同,他们很可能是重复的。


我需要一种方法来列出这些重复项。


tabledata:


personid     1

firstname    "Carl"

lastname     "Anderson"

addressindex 1


personid     2

firstname    "Carl Peter"

lastname     "Anderson"

addressindex 1

我知道如果我要在所有列上完全匹配,但是我需要模糊匹配来完成这个技巧(来自上面的例子),结果如下:


Row     personid      addressindex     lastname     firstname

1       2             1                Anderson     Carl Peter

2       1             1                Anderson     Carl

.....

关于如何以一种好的方式解决这个问题的任何提示?


波斯汪
浏览 642回答 3
3回答

ibeautiful

除了这里的其他好信息,你可能还想考虑使用Double Metaphone语音算法,它通常被认为比SOUNDEX更好。Tim Pfeiffer在他的文章Double Metaphone Sounds Great C ++ Double Metaphone算法转换为T-SQL(最初在SQL Mag中然后在SQL Server Pro中)中详细介绍了SQL中的实现。这将有助于匹配名称与轻微的拼写错误,例如,卡尔与卡尔。更新:实际的可下载代码似乎已经消失了,但这是在github repo上找到的一个实现,它似乎克隆了原始代码
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

SQL Server