Last active
December 7, 2023 23:58
-
-
Save lsauer/5564952 to your computer and use it in GitHub Desktop.
FullText fuzzy searching in SQL / MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lo sauer, 2013 - www.lsauer.com | |
#see: http://www.lsauer.com/2013/05/mysql-fuzzy-searching-fulltext-queries.html | |
#Note: In MySQL SUBSTRING, the string-index starts at position 1 | |
SELECT * FROM tablename | |
WHERE SOUNDEX(tablename_field) | |
LIKE CONCAT('%',SUBSTRING(SOUNDEX('Fuzti serch derm'),2),'%'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUBSTRING("fb stands for foobar",1); | |
#"fb stands for foobar" | |
SELECT SOUNDEX("fb"); | |
#F000 | |
SELECT SOUNDEX("fbs"); | |
#F200 | |
SELECT SOUNDEX("stands"); | |
#S3532 | |
SELECT SOUNDEX("for"); | |
#F600 | |
SELECT SOUNDEX("foobar"); | |
#F600 | |
SELECT SOUNDEX("for foobar"); | |
#F616 | |
SELECT SOUNDEX("sfor foobar"); | |
#F1616 | |
SELECT SOUNDEX("fb stands for foobar"); | |
#F2 3532 1616; spaces are for clarity |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment