For example, I have a table containing well log data for multiple operable units. I would like to make a query outputting a table where Operable unit=001 OR 002, AND Formation= Residuum. I would like to first select only values where operable unit equals 001 or 002, and then from those values select only those where the formation=residuum.

Currently the output from [OU] = '001' OR '002' AND [Formation] = 'Residuum', will output a table that will include other operable units as long as the formation=residuum.

I am using ArcMap 10.

  • 3
    Did you try using parentheses? ([OU] = '001' OR [OU]= '002') AND [Formation] = 'Residuum' ? – Kirk Kuykendall Apr 25 '16 at 20:54
  • 4
    [OU] IN ('001', '002') AND [Formation] = 'Residuum' – Richard Fairhurst Apr 25 '16 at 21:08
  • 2
    I like Richard's better. – Kirk Kuykendall Apr 25 '16 at 21:10
  • The expression using IN worked for me. Thank you very much for your help! @RichardFairhurst – zanwigz May 1 '16 at 20:42

I am posting this just so you can mark this format as the answer.

The IN syntax is the most compact way to write the expression you want:

[OU] IN ('001', '002') AND [Formation] = 'Residuum'


Perhaps an expression like this would work better:

[OU] = '001' AND [Formation] = 'Residuum' OR [OU] = '002' AND [Formation] = 'Residuum'

It's a little tedious in its formatting, but should return the results that you're after.

A little more elegant expression would be:

([OU] = '001' OR [OU] = '002') AND [Formation] = 'Residuum'

Either one should produce the same result.

  • Thank you! Both of these expressions worked. It is interesting to me that ([OU]='001' OR '002') will output a different expression than ([OU]='001' OR [OU]='002'). It seems to me I need to learn a little more about the logic of SQL. – zanwigz May 1 '16 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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