Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHPMySQL
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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 480
1 Tadit Dash 305
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 190
4 OriginalGriff 163
0 Sergey Alexandrovich Kryukov 9,435
1 OriginalGriff 5,498
2 Peter Leow 4,230
3 Maciej Los 3,540
4 Abhinav S 3,353


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 24 May 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid