MySQL Forums
Forum List  »  Newbie

Re: similar string matches
Posted by: Ramalingam Chelliah
Date: August 23, 2004 04:09AM

Hi,
I thought that you liked to get all High Schools containing "Stanford" in their names...

But now I presume that You *also* want to get all those high schools
with their names somehow a substring of UserInput ...

Here is my trial using INSTR(str,substr) function..

This will get user input($x) and gets school names which are substring of $x and also those school names of which $x is a substring

Assuming Table name to be 'school' and field name to be 'HSchool'

mysql>SELECT * FROM school
WHERE INSTR(HSchool,$x)>0 OR INSTR($x,HSchool)>0;

For your user input "Carl Sandburg High School" it should be like...

mysql>SELECT * FROM school
WHERE INSTR(Hschool,'Carl Sandburg High School')>0
OR
INSTR('Carl Sandburg High School',HSchool)>0 ;

Hope this helps ...

Regards,
Ram.

P.S : For this to work the searched keyword should atleast be in order
'Carl High School Sandburg' won't list 'Carl Sandburg Hish School'
but it will list 'Carl' if there is some entry like that...

For String Functions
Refer: http://dev.mysql.com/doc/mysql/en/String_functions.html






We Learn the Most When we have to Invent

Options: ReplyQuote


Subject
Written By
Posted
August 20, 2004 04:25PM
August 21, 2004 08:29AM
Re: similar string matches
August 23, 2004 04:09AM
August 23, 2004 09:08AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.