MariaDB 函数

MariaDB SOUNDS LIKE 语句用于比较两个表达式的 soundex 字符串。它用作expr1 SOUNDS LIKE expr2,与SOUNDEX(expr1 ) = SOUNDEX(expr2)。

语法

expr1 SOUNDS LIKE expr2 

参数

expr1必需。 指定需要比较的第一个表达式。
expr2必填。 指定需要比较的第二个表达式。

返回值

比较两个表达式的 soundex 字符串和返回结果。

示例 1:

下面的示例显示了 SOUNDS LIKE 语句的用法:

SELECT 'Here' SOUNDS LIKE 'Heir';
Result: 1

SELECT 'Principal' SOUNDS LIKE 'Principle';
Result: 1

SELECT 'Anothers' SOUNDS LIKE 'Brothers';
Result: 0

SELECT 'There' SOUNDS LIKE 'Their';
Result: 1

SELECT 'Except' SOUNDS LIKE 'Accept';
Result: 0

SELECT 'Cache' SOUNDS LIKE 'Cash';
Result: 1 

示例 2:

考虑一个名为 Employee 的数据库表,其中包含以下记录:

EmpIDFirstNameLastName
1JohnSmith
2MarryKnight
3JoWilliams
4KimSmythe
5RameshGupta
6HuangZhang

要从此表中选择 LastName 的所有记录 SOUNDS LIKE "Smythe",可以使用以下查询:

SELECT * FROM Employee
WHERE LastName SOUNDS LIKE 'Smythe'; 

这将产生如下所示的结果:

EmpIDFirstNameLastName
1JohnSmith
4KimSmythe