title: How to write where clause with joining 2 tables, having ORs in the clause
body: <p>I have 2 tables <code>A_ORDERS</code> and <code>A_ORDERS_LOG</code>. Columns of interest in table <code>A_ORDERS</code> are <code>PEN</code> and <code>SKL</code>, and Columns in table <code>A_ORDERS_LOG</code> that are of interest are <code>Status1</code> and <code>Status2</code> as well as <code>DATE</code> (just for ordering my result). <code>PEN</code> is unique.</p>
  
  <p>This is what I have </p>
  
  <pre><code>select
   l.pen,status1,status2,date,a.skl 
  
  from A_ORDERS_LOG l
  
  join A_ORDERS a on l.PEN=a.PEN 
  
  where a.skl='XY'
  
  and status1='75' or status1='13'
  
  and status2='13' or status2='11'
  
  order by l.id,l.date;
  </code></pre>
  
  <p>I get all the rows for all the other skl's there are in the table <code>A_ORDERS</code>, but I only want rows regarding <code>skl=XY</code> from <code>A_ORDERS</code>. The thing is that PENs travel through different status and I want all the rows for each <code>PEN</code> where it went through possible status from 75 to 13 and then from 13 to 11. </p>
  
  <p>When I put it like this I get what I want. </p>
  
  <pre><code>and (status1='75' or status1='13')
  and (status2='13' or status2='11');
  </code></pre>
  
  <p>Why is that?</p>
  
  <p>Thanks in advance :)</p>