I love finding out new things about MySQL. Last week, I stumbled on a query that had the phrase “SOUNDS LIKE” in it. Sounds made-up, right? Turns out MySQL is using a known “soundex” algorithm common to most databases, and popular in use cases in geneaology.
The basic idea is that words are encoded according to their consonants. Consonants that sound similar (like M and N) are given the same code. Here’s a simple example:
(“soundex” and “sounds like” are different ways of doing the same thing in these queries)
MariaDB> select soundex("boom"); +-----------------+ | soundex("boom") | +-----------------+ | B500 | +-----------------+ MariaDB> select soundex("bam"); +----------------+ | soundex("bam") | +----------------+ | B500 | +----------------+ MariaDB> select soundex("bin"); +----------------+ | soundex("bin") | +----------------+ | B500 | +----------------+
…
[Read more]