Home > Archive > PHP SQL > September 2005 > Compare phone numbers ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Compare phone numbers ?
|
|
| Damien 2005-09-01, 7:56 am |
| Hi to all,
I'm trying to compare a phone number (entered in a form field) with
another from a database (MySQL). Problem is, neither are formatted: the
French style may use dots, slashes, spaces, hyphens to separate the
digit groups.
eg: the user could enter +33 3 87 00 00 00 and want to see records like
: +33387000000 or +33/3/00/00/00.
How can I compare only the digits and return matching rows ? Is it
possible in a single MySQL query ?
Thanks a lot in advance !
BR,
Damien
--
"So you're just taking your caffeine level past the medical definition
of 'stimulant' into the 'poisons' category?"
Bastard Operator From Hell
| |
| ZeldorBlat 2005-09-01, 6:57 pm |
| I would normalize all your data when you put it into the database. The
easiest way would be to remove any character that is not a digit before
inserting. Then the comparison is easy! You can still format the
number to show it on the page, but I wouldn't do this until you're
ready to display it.
| |
| Hilarion 2005-09-01, 6:57 pm |
| ZeldorBlat <zeldorblat@gmail.com> wrote:
>I would normalize all your data when you put it into the database. The
> easiest way would be to remove any character that is not a digit before
> inserting. Then the comparison is easy! You can still format the
> number to show it on the page, but I wouldn't do this until you're
> ready to display it.
One can also use both data - store the data as user entered it,
and also (in separate field) normalized data (the field could
be filled with a trigger). This way you can check (and display)
the data the way it was entered, use normalized version for searching
and for normalized or specificaly formatted output.
Hilarion
|
|
|
|
|