title: mysql select where count = 0
body: <p>In my db, I have a "sales" table and a "sales_item". Sometimes, something goes wrong and the sale is recorded but not the sales item's.<br>
  So I'm trying to get the salesID from my table "sales" that haven't got any rows in the sales_item table.</p>
  
  <p>Here's the mysql query I thought would work, but it doesn't:  </p>
  
  <pre><code>SELECT s.*
  FROM sales s NATURAL JOIN sales_item si
  WHERE s.date like '" . ((isset($_GET['date'])) ? $_GET['date'] : date("Y-m-d")) . "%'
  AND s.sales_id like '" . ((isset($_GET['shop'])) ? $_GET['shop'] : substr($_COOKIE['shop'], 0, 3)) ."%'
  HAVING count(si.sales_item_id) = 0;
  </code></pre>
  
  <p>Any thoughts?</p>