List:General Discussion« Previous MessageNext Message »
From:Rick Dwyer Date:November 17 2005 3:28pm
Subject:A bit of SQL help for a MySQL novice.
View as plain text  
Hello All.

I am hoping for a bit of help with some code that has really given me  
some trouble.  If this is not he correct forum for this any help in  
pointing me to a more suited list would be appreciated.

I have a MySQL 4.1.x database containing records with phone numbers.

Most of the phone numbers are enter in 12035551212 format, but some  
are entered with spaces or "-" or "(" or other characters.

I need to read the first 4 positions in the phone number to determine  
it's location.

My statement looks like this:
'Select mid(phone, 1,4) as phoneareacode from phonetable'

This works but if the number is entered as 1(203)-555-1212 the above  
would return   "1(20" which is not what I am looking for.

Is there a way to have the select statement examine only numeric  
values in the phone number so it would disregard the other charcters?

In Lasso, you can use a Replace with a Regular Expression function to  
have just the digits 0-9 examined but haven't been able find  a way  
to do this in SQL.

Any help is appreciated.
Thank you.
Rick







Thread
A bit of SQL help for a MySQL novice.Rick Dwyer17 Nov
  • Re: A bit of SQL help for a MySQL novice.SGreen17 Nov
  • Re: A bit of SQL help for a MySQL novice.Rhino17 Nov
    • Re: A bit of SQL help for a MySQL novice.Rick Dwyer17 Nov
  • Re: A bit of SQL help for a MySQL novice.Rhino17 Nov
  • Re: A bit of SQL help for a MySQL novice.Peter Brawley17 Nov
RE: A bit of SQL help for a MySQL novice.Mikhail Berman17 Nov