> On 25 Feb 2015, at 24:50, Tim Smith wrote:
>
> Have an Oracle "connect by" SQL that looks something like :
>
> select phone, pfx, len, (select info from codes where
> pfx = x.pfx) infot
> from (
> select :x phone, to_number(substr( :x, 1, length(:x)-level+1 )) pfx,
> length(:x)-level+1 len
>
Some other solutions
http://postgres.cz/wiki/PostgreSQL_SQL_Tricks_II#Fast_searching_of_longer_prefix
2015-02-25 9:04 GMT+01:00 Tim Smith :
> Will take a look. Thanks steve.
>
> On 24 February 2015 at 23:57, Steve Atkins wrote:
> >
> > On Feb 24, 2015, at 3:50 PM, Tim Smith
> wrote:
> >
> >>
Will take a look. Thanks steve.
On 24 February 2015 at 23:57, Steve Atkins wrote:
>
> On Feb 24, 2015, at 3:50 PM, Tim Smith wrote:
>
>>
>>
>> The goal being to match the longest prefix given a full phone number, e.g.
>>
>>
>> 61234567890 would match "australia proper 61"
>> whilst
>> 61134567
On Feb 24, 2015, at 3:50 PM, Tim Smith wrote:
>
>
> The goal being to match the longest prefix given a full phone number, e.g.
>
>
> 61234567890 would match "australia proper 61"
> whilst
> 61134567890 would match "Australia premium 6113"
> and
> 61894321010 would match "Australia - Sydney
Have an Oracle "connect by" SQL that looks something like :
select phone, pfx, len, (select info from codes where
pfx = x.pfx) infot
from (
select :x phone, to_number(substr( :x, 1, length(:x)-level+1 )) pfx,
length(:x)-level+1 len
from dual
connect by level <= length(:x)
order by level