#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    9
    Rep Power
    0
    I have a database which is searchable by zip code and I want to also make it searchable by area code and prefix.
    I have the form set up where the user can enter an area code and a prefix.
    In the database one of the fields is 'Phone'.
    Question:
    Is it possible to select the records in the database by comparing the form input to only the first 6 digits of the 'phone' field??
    Any help is appreciated.
    Thanks,
    jim
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Location
    London, England
    Posts
    251
    Rep Power
    15
    Have you tried using the LEFT function?

    LEFT(string, length) returns length characters from the start (left end) of string.

    So you could query:

    SELECT *
    FROM yourtable
    WHERE LEFT(phone, 6) = 'yoursearchterm';


  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    9
    Rep Power
    0
    That will do it.
    Almost sounds logical doesn't it? 8-)
    Thanks,
    Jim

Similar Threads

  1. Wan to select partial text in a text field
    By raghava66 in forum HTML Programming
    Replies: 2
    Last Post: February 12th, 2004, 03:11 AM
  2. searching partial and complete words
    By Sir Fragalot in forum MySQL Help
    Replies: 6
    Last Post: January 30th, 2004, 04:02 PM
  3. Searching only date in datetime field
    By jasonm in forum MySQL Help
    Replies: 1
    Last Post: June 12th, 2003, 09:03 AM
  4. 1 field or 30 fields? Efficient Searching
    By bagger in forum PHP Development
    Replies: 7
    Last Post: June 11th, 2003, 04:06 AM
  5. Database design question
    By mcsimon in forum Dev Shed Lounge
    Replies: 2
    Last Post: August 5th, 2001, 01:17 AM

IMN logo majestic logo threadwatch logo seochat tools logo