title: MySQL How to check for qty of intersecting dates with a range?
body: <p>I can query quantities based on <code>'date'</code> OR <code>'dateLast'</code> but do not understand how to get a quantity when the date is between <code>'date'</code> and <code>'dateLast'</code></p>
  
  <p>This query works and shows the basic logic but it does not use the <code>'endDate'</code> to determine dates in between. How do I iterate the in between dates to check against a value (7) to collect those that are over?</p>
  
  <p>Sample data:</p>
  
  <pre><code>CREATE TABLE test (
    `id` int(20) NOT NULL,
    `date` date DEFAULT NULL,
    `dateLast` date DEFAULT NULL,
    `mid` int
  );
  
  INSERT INTO `test` (`id`, `date`, `dateLast`, `mid`) VALUES
  (1, '2019-03-19', '2019-03-21', 22),
  (2, '2019-03-18', '2019-03-25', 22),
  (3, '2019-03-19', '2019-03-20', 22),
  (4, '2019-03-19', '2019-03-20', 22),
  (5, '2019-03-19', '2019-03-20', 22),
  (6, '2019-03-19', '2019-03-20', 22),
  (7, '2019-03-19', '2019-03-20', 22),
  (8, '2019-03-19', '2019-03-20', 22),
  (9, '2019-03-19', '2019-03-20', 22);
  </code></pre>
  
  <p>My query:</p>
  
  <pre><code>SELECT
      reservations.date,
      COUNT(*) AS Qty
  FROM
      reservations
  WHERE
      reservations.mid = 22
      AND Qty &gt;=7
  GROUP BY
      reservations.date
  </code></pre>