title: In SQL, what does using parentheses with an OR mean?
body: <p>Example:</p>
  
  <pre><code>select count(*) from my table
  where
  column1 is not null
  and
  (column1 = 4 OR column1 = 5)
  </code></pre>
  
  <p>Example 2:</p>
  
  <pre><code>select count(*) from my table
  where
  column1 is not null
  and
  column1 = 4 OR column1 = 5
  </code></pre>
  
  <p>In my database with the real column names, I get two different results.  The one with the parentheses is right because if I do:</p>
  
  <pre><code>select count(*) from my table
  where
  column1 is not null
  and
  column1 = 4
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>select count(*) from my table
  where
  column1 is not null
  and
  column1 = 5
  </code></pre>
  
  <p>and add them together, I get the right answer...I think.  Same as the first example with the parentheses above.</p>
  
  <p>Why do I get different results by changing precedence with the OR test?</p>