| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Reverse pattern matching
Gary Greenberg wrote:
> I encountered an unusual problem and wonder if anyone had some
similar
> experience. I have a table T where the column contains text values
with
> wild cards and a query contain exact value. For example
> ------------------------
> | A | B |
> ------------------------
> |AB% | 1 |
> |X% | 2 |
> |XY% | 3 |
> |% | 4 |
> ------------------------
>
> I'd like to make a query "select B from T where A like 'XYZ'"
> I need to get a result sorted by maximum matching. For the liset case
it
> should be:
> 3
> 2
> 4
>
> Any help will be greatly appreciated.
x like 'AB%'
is roughly equivalent to
x between 'ABAAAA...' and 'ABZZZZZ...'
where A is the first symbol in ASCII range and Z is the last one. Therefore, a pattern with trailing % (and all pattelns you have seems to meet this criteria) is an interval!
Therefore, your reverse pattern matching problem is essentially the
following:
Given a set (or a table) of intervals, find all the intervals that
cover a given point. You would have no problem to make this statement
formal as a query, although having an efficient access path via an
index is a challenge.
Received on Wed May 18 2005 - 11:54:32 CDT
![]() |
![]() |