Using SOUNDEX function on WHERE clause in MySQL

595 Views Asked by At

How can I use soundex function on the following WHERE clause?

WHERE usr.name LIKE CONCAT('%', :search, '%')

Given that the general approach for using SOUNDEX function is:

SELECT name FROM users WHERE soundex('Dennis') = soundex(name)

However, I am getting confused on how to code it on the above where clause as I have used LIKE. I am using MySQL and PDO.

1

There are 1 best solutions below

0
Relaxing Music On

I got the answer. Posting for someone searching in future.

WHERE (soundex(:search) = soundex(usr.name)) OR (usr.name LIKE CONCAT('%', :search, '%'))