Results 1 to 6 of 6

Thread: Phone Number Lookup Query!!

  1. #1
    Join Date
    May 2004
    Location
    Florida, USA
    Posts
    29

    Phone Number Lookup Query!!

    i am trying to write a query for phone number lookup . The query should be able to search numbers which have anything matching ....
    like if the person enters 1918767899 or enters 918767899 the query should be able to find both the records. Itried using the LIKE , but it doesn't work the way it is required.

    Pls help !!

    Regards

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    What's data type for the column? How does your query look like?

  3. #3
    Join Date
    May 2004
    Location
    Florida, USA
    Posts
    29
    SELECT * FROM phonebook
    WHERE (phone_number LIKE @phone)

    (where @phone comes from my C# application and has a value '%9179567898%' )

    The problem is if the person enters the number 19179567898 , it will not find the number if the database recored have 9179567898 .


    Any help is appreciated !!!

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    May add check logic in your frontend to ensure that leading 1 is not allowed.

  5. #5
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    How about this...

    Search for both
    '%19179567898%' or '%9179567898%'

  6. #6
    Join Date
    Jun 2004
    Posts
    1
    Have You tried

    SELECT * FROM phonebook
    WHERE (phone_number LIKE @phone) or (@phone like '%'+phone_number+'%')?

    This should return 9179567898 for @phone = 19179567898, but it will also return entries with phone numbers like '9179' or '56789'!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •