What is the proper structure for searching within MySql using soundex()
? I know how to produce a soundex():
select soundex('str');
just not sure how to include this in my query.
If you're searching for "lewis" against the name
field of people
table, you perform this query:
SELECT *
FROM people
WHERE soundex("lewis") = soundex(name);
example here
Obviously, soundex isn't designed for partials like this (e.g. SELECT SOUNDEX('house cleaning'), SOUNDEX('house')
, which would not match), but if you would like to perform a nasty SOUNDEX LIKE
, you could
SELECT * FROM tablename WHERE SOUNDEX(column) LIKE CONCAT(SOUNDEX('partial_string'), '%')
You could also do
SELECT * FROM tablename WHERE SOUNDEX(column) LIKE CONCAT(TRIM(TRAILING '0' FROM SOUNDEX('hows ')), '%')
This "kinda" works
This should work
select * from table_name where soundex(column_name) = soundex('word');
This is a good place to read about these:http://www.postgresonline.com/journal/archives/158-Where-is-soundex-and-other-warm-and-fuzzy-string-things.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With