tags:

views:

24

answers:

1

I have 2 area codes I need to match in my database the area code is 214 and 927 I am using the LIKE clause

 select * test where phone like "*972*"

I believe if 972 is anywhere in the phone number it will be matched. I need 972 to be only matched with the area code.

The phone formats can be (###) ### - #### or ##########

Is this possible to do in access?

+1  A: 

Try:

select * from test where left(phone, 3) = "972" -- for ########## format

Or:

select * from test where left(phone, 5) = "(972)" -- for (###) ### - #### format
Robert
thanks so much.
Luke101
I believe that if your phone number field is indexed, a LIKE will used the index if you are matching on the beginning of the field, so LIKE "(972)*" or LIKE "927*" should be more efficient than testing the result of the Left function.
David-W-Fenton