Get names that sound like "Gary Miller"
mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS party
-> (
-> id INT AUTO_INCREMENT PRIMARY KEY,
-> dept CHAR(10), name CHAR(25)
-> );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> # insert 3 records into the "party" table
mysql> INSERT INTO party (dept, name) VALUES ("accounts", "Graham Miller");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO party (dept, name) VALUES ("sales", "Gary Miller");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO party (dept, name) VALUES ("production", "Graham Wallace");
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # get names that sound like "Gary Miller"
mysql> SELECT SOUNDEX(name),name FROM party
-> WHERE SOUNDEX(name) = SOUNDEX("Gary Miller");
+---------------+---------------+
| SOUNDEX(name) | name |
+---------------+---------------+
| G6546 | Graham Miller |
| G6546 | Gary Miller |
+---------------+---------------+
2 rows in set (0.00 sec)
mysql>
mysql> # delete this sample table
mysql> DROP TABLE IF EXISTS party;
Query OK, 0 rows affected (0.00 sec)
mysql>
Related examples in the same category