Luke101
Luke101

Reputation: 65298

How to match an area code in MS access

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?

Upvotes: 0

Views: 2221

Answers (1)

Sesame
Sesame

Reputation: 3410

Try:

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

Or:

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

Upvotes: 1

Related Questions