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开发者_StackOverflow社区 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?
Try:
select * from test where left(phone, 3) = "972" -- for ########## format
Or:
select * from test where left(phone, 5) = "(972)" -- for (###) ### - #### format
精彩评论