Re: How to best match strings

From: Ranga Chakravarthi <ranga_at_removethis.cfl.rr.com>
Date: Fri, 23 Aug 2002 00:06:39 GMT
Message-ID: <j0f99.360234$XH.8173718_at_twister.tampabay.rr.com>


Hi,

SELECT <columns>
FROM <table>
WHERE <primary_field> LIKE SUBSTR(<input>, 1, 2) || '%'

will give you all the rows in the table where the first two characters of the primary key field matches the first two characters of the input field
HTH,
Ranga Chakravarthi

"Loai Garelnabi" <gloai_at_hotmail.com> 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 Fri Aug 23 2002 - 02:06:39 CEST

Original text of this message