From: | Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my> |
---|---|
To: | "J(dot) Greenlees" <jaqui(at)telus(dot)net> |
Cc: | Russ Brown <pickscrape(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: regular expressions in query |
Date: | 2005-02-15 13:22:55 |
Message-ID: | 5.2.1.1.1.20050215211154.03801490@localhost |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
But that method would be specific for searches for the last 4 digits. It
won't work as well for the general case of the last X digits.
To clarify the method I suggested:
Say a phone number is: 818 9567 1234
You reverse the number and store it as text and index it as
43217659818
Then if someone searches for 5671234 you reverse the query string and do a
search for
select * from phonebook where number like '4321765%' and ....
If they enter just the last 5 digits: 71234
select * from phonebook where number like '43217%' and ....
These sort of searches are indexable on postgresql.
Link.
At 04:33 AM 2/13/2005 -0800, J. Greenlees wrote:
>Lincoln Yeoh wrote:
>I think it should. But for phone numbers it may be better to reverse the
>digits before indexing - usually whilst the area code changes, the last 4
>or 5 digits don't change.
>>This way you can do a LIKE search on *5678. Where the number ends with 5678.
>make sure the table stores as text rather than as numeric data.
>then you can use the excellent perl string tools to pull the last 4
>characters of the number.
>
>$base=((strlen-4,strlen)
>
>$base being the last 4 digits.
>then convert to numeric to test against search requirements.
>
>Jaqui
From | Date | Subject | |
---|---|---|---|
Next Message | David Parker | 2005-02-15 13:37:32 | Re: [Slony1-general] Re: Slony uninstall info/warning |
Previous Message | John Sidney-Woollett | 2005-02-15 12:33:03 | Re: Slony uninstall info/warning |