Relaxing Music
Relaxing Music

Reputation: 472

Using SOUNDEX function on WHERE clause in MySQL

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.

Upvotes: 0

Views: 916

Answers (1)

Relaxing Music
Relaxing Music

Reputation: 472

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

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

Upvotes: 1

Related Questions