如果你改变了单词的顺序,你会发现第一个单词有偏差.然后,如果你考虑SOUNDEX,你就会开始理解为什么.也请阅读下面的参考资料.
Soundex将字母数字字符串转换为四个字符的代码,该代码基于字符串在英语中的发音.这个
代码的第一个字符是的第一个字符
CHARACTER_EXPRESS,转换为大写.第二个到第二个
代码的第四个字符是代表字母的数字
在表达式中.字母A、E、I、O、U、H、W和Y将被忽略
除非它们是字符串的第一个字母.将零添加到
如有必要,结束,以产生四个字符的代码.了解更多
有关Soundex代码的信息,请参阅The Soundex Indexing
System
-- Bias based on left to right order of words
SELECT 10 id, DIFFERENCE('Good', 'Good Samaritans') --Result is 4 (High score match)
union all
SELECT 11 id, DIFFERENCE('Good', 'Samaritans Good') --Result is 1 (Low score match)
union all
SELECT 20, DIFFERENCE('Samaritans', 'Good Samaritans') --Result is 1 (Low score match)
union all
SELECT 21, DIFFERENCE('Samaritans', 'Samaritans Good') --Result is 4 (High score match)
union all
SELECT 30, DIFFERENCE('Sam', 'Good Samaritans') --Result is 2 (On the upper low side)
id |
(No column name) |
10 |
4 |
11 |
1 |
20 |
1 |
21 |
4 |
30 |
2 |
fiddle个
你对difference
岁的期望可能太高了.