Re: Does MySQL have fuzzy matching or no?
Date: Fri, 15 Dec 2017 11:23:08 -0500
Message-ID: <p10st5$nqv$1_at_dont-email.me>
bit-naughty_at_hotmail.com wrote:
> I want to know - if there is a string, say, "poop" in a field in a table,
> and I want to match it against the string "doop", and have the search
> return successful - can I? How, please?
[Quoted] If you are looking at strings that might sound similar if pronounced, then
you could use the SOUNDEX() function to match to a pre-determined value, or
the SOUNDS LIKE operator (which is, effectively, SOUNDEX(a) = SOUNDEX(b) )
to match to something else.
SELECT * FROM table
WHERE field1 SOUNDS LIKE field2 ;
If, OTOH, you are looking at strings that might be spelled similarly, you
could use a REGEXP() function to match to variations in character sequence.
SELECT * FROM table
WHERE field1 REGEXP '[pd]oop' ;
If you are looking for substrings within freeform strings, you can MATCH
AGAINST IN NATURAL LANGUAGE MODE.
SELECT * FROM table
WHERE MATCH (field1) AGAINST ('poop' IN NATURAL LANGUAGE MODE) ;
-- Lew Pitcher "In Skills, We Trust" PGP public key available upon requestReceived on Fri Dec 15 2017 - 17:23:08 CET