title: MySQL Where on Multiple Left Join Rows
body: <p>I have a MySQL Left Join Query that returns 1 row from table A and multiple rows from table B. I need to have multiple WHERE clauses on these rows and only return if all of the B rows match.</p>
  
  <p>I have:</p>
  
  <pre><code>SELECT 
  
  mage_sales_order.entity_id
  
  FROM mage_sales_order 
  
  LEFT JOIN mage_sales_order_item 
  ON mage_sales_order.entity_id = mage_sales_order_item.order_id 
  
  WHERE 
  
   mage_sales_order_item.sku NOT LIKE '1-%' 
   AND mage_sales_order_item.sku LIKE '2-%' 
  
   ## Group order IDs together 
   GROUP BY entity_id
  </code></pre>
  
  <p>However this will return any order that has an item with the SKU starting with "2-" even if it has an item starting with "1-". I want it so that orders only with items starting with "2-" are returned.</p>
  
  <p>For example:</p>
  
  <p>Should be returned:</p>
  
  <ul>
  <li>Order 1 (mage_sales_order)
  
  <ul>
  <li>2-sampleA-sku (mage_sales_order_item)</li>
  <li>2-sampleB-sku (mage_sales_order_item)</li>
  </ul></li>
  </ul>
  
  <p>Should not be returned:</p>
  
  <ul>
  <li>Order 1 (mage_sales_order)
  
  <ul>
  <li>1-sample-sku (mage_sales_order_item)</li>
  <li>2-sampleA-sku (mage_sales_order_item)</li>
  <li>2-sampleB-sku (mage_sales_order_item)</li>
  </ul></li>
  </ul>
  
  <p>I assume this has already been asked but trying to search for it is proving difficult.</p>