以下是 SQL 中的 Soundex 代码示例:
SELECT SOUNDEX('Smith'), SOUNDEX('Smythe');
----- -----
S530 S530
'Smith'
如何变成 S530
?
在此示例中,第一个数字是 S
,因为这是输入表达式中的第一个字符,但是如何计算剩余的三个数字?
最佳答案
看看这个 article
The first letter of the code corresponds to the first letter of the name. The remainder of the code consists of three digits derived from the syllables of the word according to the following code:
- 1 = B, F, P, V
- 2 = C, G, J, K, Q, S, X, Z
- 3 = D, T
- 4 = L
- 5 = M,N
- 6 = R
The double letters with the same Soundex code, A, E, I, O, U, H, W, Y, and some prefixes are being disregarded...
因此,对于 Smith 和 Smythe,代码是这样创建的:
S S -> S
m m -> 5
i y -> 0
t t -> 3
h h -> 0
e -> -
关于sql - Soundex 函数在 SQL Server 中如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7295812/