why soundex return irrelevant result

问题: I wonder why : WHERE 1=1 AND LTRIM(RTRIM(lastName)) ='Schmdli' OR ( SOUNDEX(lastName) = SOUNDEX('Schmdli') ) Return me...

问题:

I wonder why :

  WHERE 1=1 
    AND   LTRIM(RTRIM(lastName)) ='Schmdli' 
        OR ( 
                SOUNDEX(lastName) = SOUNDEX('Schmdli')
            )

Return me result like

lastName
Schöntal
Schindler-Külling
Schindler
Schmidlin
Schindler
Schmidli
Schmidli
Schindler

while I expect only:

Schmidli
Schmidli
Schmidlin

My first AND LTRIM(RTRIM(lastName)) ='Schmdli' is to match exact value then with soundex I expect better near Schmdli result here some result like

Schöntal
Schindler-Külling
Schindler

shouldn't appear.

Thanks


回答1:

Trivial answer: because SOUNDEX is a simple algorithm with limited space (one letter and three digits), and all of your examples happen to translate to the same one, S534, only taking into account the letters S, C, M and D. Incidentally, Schöntal only takes into account S, C, N and T, producing the same output since M and N encode in the same way, as do D and T.

  • 发表于 2018-07-08 10:03
  • 阅读 ( 219 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除