Re: How to best match strings

From: Loai Garelnabi <gloai_at_hotmail.com>
Date: 23 Aug 2002 21:55:27 -0700
Message-ID: <804a1aa9.0208232055.da8cb6e_at_posting.google.com>


I'm sorry, but I forgot to mention that I need only the best macth string, e.g., if the table contains 'hell' and 'hello', and the input was 'hello', the query should only return 'hello'. The other thing to keep in mind is that the input is of variable length, between 2 and 7 characters. This is forcing me at the moment to run multiple queries with different substrings of the input string. My goal is to minimize the number of queries I'm using to identify the best match.

jusungyang_at_yahoo.com (Jusung Yang) wrote in message news:<42ffa8fa.0208221749.552e6823_at_posting.google.com>...
> Wouldn't something simple like this solve your problem?
>
> select * from <table_name> where
> substr(<column_name>,1,1)=substr(<variable_name>,1,1);
>
> or did I misunderstand your problem? You can build a function based
> index with substr on the column in question to boost the performance.
>
>
>
> gloai_at_hotmail.com (Loai Garelnabi) wrote in message news:<804a1aa9.0208220800.4683e155_at_posting.google.com>...
> > I have a table where the primary key field can have values that range
> > in length between 2 and 7 characters.A client application has an input
> > of a string that has a length of exactly 7 characters. The application
> > need to identify the row whose primary field contains the substring
> > that the input string starts with, e.g, Input is 'hello', then the
> > following rows apply, 'he', 'hello'. The approach I'm using now is to
> > select from the table using the whole string. If no data was found,
> > then I select using a substring of the input string without the last
> > character, and another select without the laste two characters, and so
> > on until I find the rows I need.
> > I find this approach slow and resource consuming. Can someon suggest a
> > more efficient approach.
> > Thanx
Received on Sat Aug 24 2002 - 06:55:27 CEST

Original text of this message