Click here to Skip to main content
Rate this: bad
good
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
good
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'
  Permalink  
Comments
rashidfarooq at 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 at 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 ?
http://www.imranulhoque.com/mysql/mysql-function-soundex-match-multi-word-string/
rashidfarooq at 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 at 25-May-11 4:14am
   
I long time a go, I found this PDF file.
http://nlp.stanford.edu/IR-book/pdf/irbookonlinereading.pdf
 
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)



Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 24 May 2011
Copyright © CodeProject, 1999-2014
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