2

Possible Duplicate:
Is there a combination of “LIKE” and “IN” in SQL?

The first where clause below runs fine for me but it does not pick up contacts that might have 45211-1234 or 45213-4321

SELECT * FROM contacts
WHERE zipcode IN ('45211','45213')

I thought I could change the where clause to the below to fix, but it fails.

SELECT * FROM contacts
WHERE zipcode IN ('45211%','45213%')

How might I change this so it brings back anything that has proper zip + dash + any zip4? For example, 45211-1234 or 45213-4321.

Note I have whole bunch of zipcodes to enter, not just these two.

0

1 Answer 1

3

How about this:

SELECT * FROM contacts
WHERE Left(zipcode,5) IN ('45211','45213')
Sign up to request clarification or add additional context in comments.

1 Comment

Works great and simple for me to understand. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.