Jump to content

[SOLVED] Telephone Database


yoki

Recommended Posts

Hi,

 

I'm rather new to setting up a MySQL database and was wondering if someone could suggest me a way of storing phone numbers.  I'm planning to update my database with a .csv file which will contain the phone numbers in this format:

 

514,2544395

514,6549082

.

.

.

 

I want to be able to search for a phone number by first selecting the area code in a dropdown and then entering the number in another field.

 

Should I split the telephone number into two tables?  One table for the area code and one for the telephone number?

 

Any good suggestions would be appreciated.

Link to comment
Share on other sites

I'd just store them as

 

5142544395

5146549082

 

You can find all the 514 numbers with

 

SELECT phone FROM table WHERE phone LIKE '514%'

 

Also, you can get the area codes for your dropdown with

 

SELECT DISTINCT LEFT(phone, 3) as areacode FROM table

 

You can format on output with something like this

http://www.phpfreaks.com/forums/index.php/topic,208588.msg948466.html#msg948466

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.