Subject Re: String Calc/Index
Author Adam
--- In firebird-support@yahoogroups.com, "Alan McDonald" <alan@...> wrote:
>
> I have a column containing mobile phone numbers in the following format
> 04XX XXX XXX
> I need to search this table efficiently based on a known number in the
> format
> 04XXXXXXXX
> So I need to either create a calculated column or an index which will
> provide efficiency in
> SELECT ID FROM TABLE WHERE MYCOLUMN='04XXXXXXXX'
>
> Does anyone have any ideas of the best way?
>
> In Delphi I just have a stripspaces and trim function which does the
job for
> comparison. This is fine when I move thru a subset of the values but I'd
> like to grab the number from the entire table efficiently if possible.

I may be making assumptions about the phone numbering system in your
local area, but can you assume that any number starting with 04 is a
mobile and any number not starting with 04 is not?

If that assumption is OK,

SELECT ID FROM TABLE WHERE MYCOLUMN STARTING WITH '04'

With an index on TABLE.MYCOLUMN

Adam