Click here to Skip to main content
Rate this: bad
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 4: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 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 ?
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.
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
0 CHill60 380
1 Sergey Alexandrovich Kryukov 245
2 Richard MacCutchan 152
3 CPallini 150
4 Peter Leow 150
0 Sergey Alexandrovich Kryukov 9,193
1 OriginalGriff 6,786
2 Peter Leow 4,332
3 Zoltán Zörgő 3,809
4 Richard MacCutchan 2,672

Advertise | Privacy | Mobile
Web04 | 2.8.150128.1 | Last Updated 24 May 2011
Copyright © CodeProject, 1999-2015
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