Reputation: 9
I have some very basic beginner SQL knowledge. I've come across SOUNDEX and LIKE and have tried to implement them in my code.
In my database, I have a names column that contains all available names for a person (first, second, third, etc).
So far it looks like this:
SELECT names, date_of_birth, information
FROM person_list as p
WHERE ((SOUNDEX(%s) = SOUNDEX(names)) OR (names LIKE CONCAT('%', %s, '%')))
This only works if the input is the full name. For example, say I had a field with 'John Smith', if I searched 'Jon Smyth', this would work fine.
However, if I wanted to only search 'Smyth', nothing would come up. And if there was a field containing 'John Thomas Smith' I wouldn't be able to search for 'Jon Smyth' and have that field come up.
How do I fuzzy search for a word or multiple words within a field? (I am also open to finding a solution using Python which I am more comfortable with!)
Thanks in advance!
Upvotes: 0
Views: 354