Re: comparing the last 4 characters...
Posted in 1995
Topics: General Discussion
In article <L1i8Zc1w165w@static.cssnet.sanford.nc.us>,
david@stat_edi.cssnet.sanford.nc.us says...
>
>My brain must be on holiday, but I can't figure out how to compare the
>last 4 digits of a telephone number to a like field in my database.
>
>something like this:
>
>select * from table1
>where table1.company = record.company
>and table1.city = record.city
>and table1.phone_no matches "*", record.phone_no[last 4 digits?]>
>Of course the above doesn't work, and to top it off record.phone_no is a
>character field and may vary in length if it is a local, long distance
or
>international number. Hmmm... What I'd give for a BASIC RIGHT$
>function!
>
>Tips, tricks, ideas, pointers to where my brain is vacationing all
>graciously accepted...
> __ _ _ __ _ >>
>| \\ __ ___ ___ __| | / _| __| |_ _ _ ___ _ _ __ ___ <<
>| | / _' \\ ' | / _' | \\_ \\/ _| ' \\| '_/ _ \\ ' \\/ _/ -_) C|~~|
>|__/\\__,_|\\_/|_\\__,_| |__/\\__|_||_|_| \\___/_||_\\__\\___| `--'
--
Try ... matches "*WXYZ" ...
You'll need to prepare a string to do it e.g.:
let lv_sql =
"select * from table1",
" where table1.company = record.company",
" and table1.city = record.city"
" and table1.phone_no matches '*",
record.phone_no[length(record.phone_no -3), length(record.phone_no) ],
"'"
prepare ...
declare ...
open ...
remember this will NOT use any indexes, strictly sequential search time !
+==============+=======================+======================+==========
+
| Andy Wilson | Mountfield Software | St Leonards-On-Sea | England
|
+--------------+-----------------------+----------------------+----------
+
| andyw@mountfield.co.uk | Compuserve 73171,3627
|
+======================================+=================================
+