-
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
-
What's data type for the column? How does your query look like?
-
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 !!!
-
May add check logic in your frontend to ensure that leading 1 is not allowed.
-
How about this...
Search for both
'%19179567898%' or '%9179567898%'
-
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
-
Forum Rules
|
|