I want to create a query that returns any combination of specific values of two different attributes. I have a feature class that has first field with values A through E and a second one that goes from 1 to 5. I want to select any features that are either A or B in the first field and either 1 or 2 in the second field. Would the following syntax be correct?

...WHERE ("field_1" = A OR "field_1" = B) AND ("field_2" = 1 OR "field_2" = 2)

or would it need to be making all the combinations?

...WHERE ("field_1" = A AND "field_2" = 1) OR ("field_1" = A AND "field_2" = 2) OR ("field_1" = B AND "field_2" = 1) OR ("field_1" = B AND "field_2" = 2)

2 Answers 2


possibly something like this should get close i would think:

"field_1" IN ('A','B') AND "field_2" IN (1,2)
  • I have never used the "IN" with arcGIS, can it be done with either the ways I wrote? Commented Apr 11, 2015 at 20:32
  • You are asking about a SQL query. This is the most efficient way to use SQL. If the data format doesn't support SQL, you need to ask the question differently (and remove SQL from the tags).
    – Vince
    Commented Apr 11, 2015 at 20:56
  • This seems like it would be easy enough to just test (the dialogs even have a expression verify button), as would your initial expressions. Now if you had tried both and not gotten your desired result, it would be a better question. @Vince that might be a bit harsh, given SQL support varies depending on underlying data format, which you're right should be specified. Use of 'feature class' implies a geodatabase, but specifying would be best because there are differences between file and personal. The statements in question are simple enough that they should work everywhere though.
    – Chris W
    Commented Apr 11, 2015 at 21:45
  • as @Vince mentioned, i think using "IN" is a pretty efficient way to go. However, in answer to the possibility of using either of the ways you mention - i don't see why it wouldn't work, although you would want to encapsulate A and B in single quotes, as they are characters, not numerals such as 1 and 2. Commented Apr 12, 2015 at 1:15

You might be able to do one Select By Attribute query with the first part of the query, and then do another Select By Attribute query with the second part of the query but change the selection method (drop-down in Select By Attribute dialog box) to 'Select from current selection'.


  1. WHERE "field_1" = A OR "field_1" = B
  2. Change the selection method to 'Select from current selection'
  3. WHERE "field_2" = 1 OR "field_2" = 2

Using one query is probably more efficient, but this is an alternative if for some reason that does not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.