Click here to Skip to main content
12,501,010 members (52,816 online)
Rate this:
Please Sign up or sign in to vote.
See more: PHP MySQL
I have to use the soundex() function with LIKE %...% in Mysql. I don't have the idea how should I write the query. I have made the query like this.

$query = "SELECT * FROM tbl_name WHERE soundex(fieldname) LIKE soundex(%'element'%)";

but it is not working.

Can Some one Help me?
Posted 24-May-11 3:27am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You cannot not use SOUNDEX[^] like that. But you can do

SELECT * FROM tbl_name WHERE fieldname SOUNDS LIKE 'element'
rashidfarooq 24-May-11 12:20pm
if I use this query there is problem in it.
Suppose user enters "day of the week" as the value for element. But in the database the field value is "week day". Then this query will miss this value. using LIKE %..% this value could not be missed. But if I use only LIKE %...% then I can not handle the spelling mistakes. So, Is there any other solution for my problem?
Kim Togo 24-May-11 15:47pm
Yes I can see the problem. In fact I have the same problem. But for the must it is a single word.
Perhaps this can help ?
rashidfarooq 24-May-11 22:54pm
thanks for reply. This function is good. But this function can not be used to search equally sounds values from mysql database. We need a proper sql query to do that. Any other Idea?
Kim Togo 25-May-11 4:14am
I long time a go, I found this PDF file.

Try look at page 43 - 3. Dictionaries and tolerant retrieval

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 24 May 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100