title: Trying to find orders that only have line items with a specific style and name
body: <p>What I need to do is find each order that only has lineitems with a specific style and names that include 'Commander' in them. </p>
  
  <p>I have two tables, orders and lineitems. Orders does not reference lineitems, but each lineitem has an order_id attached to it.</p>
  
  <pre><code>Orders
  |id   | is_presale   |  type  |  status  |
  | 1   |   1          |  sale  |  ready   |
  | 2   |   1          |  sale  |  ready   |
  | 3   |   0          |  sale  |  ready   |
  | 4   |   1          |  sale  |  ready   |
  </code></pre>
  
  <pre><code>Lineitems
  |order_id  |  style  |  name             |
  | 1        |  NM     | Commander: 1      |
  | 1        |  NM     | Commander: 2      |
  | 2        |  EX     | Commander: 2      |
  | 2        |  NM     | Commander: 2      |
  | 2        |  EX     | Something Else: 3 |
  </code></pre>
  
  <p>Here is my current query:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT COUNT(DISTINCT o.id) from orders o, lineitems l
  WHERE o.type = 'sale'
  AND o.is_presale = 1
  AND o.status &lt;&gt; 'canceled'
  AND l.order_id = o.id
  AND l.style = 'NM'
  AND l.name LIKE '%Commander%'
  </code></pre>
  
  <p>Right now, the query I built will return all orders that have lineitems that have the specific style and names but will not exclude orders that have lineitems with other styles and names on them as well.</p>
  
  <p>So if the above is a reference to the rows in the two tables, it would count both order 1 and 2 when all I want is order 1.</p>