title: Find overlapping date ranges from two tables?
body: <p>I want to filter out the IDs of Table 1 which is not in between the date range of Table 2.</p>
  
  <p>Table 1:</p>
  
  <pre><code>    Booking_ID | starts | ends
  </code></pre>
  
  <p>Table 2:</p>
  
  <pre><code>    ID | starts | ends
  </code></pre>
  
  <p>Tried to do something like this but it does not fetch the correct results. Seems like something is wrong here.</p>
  
  <pre><code>select t1.id, date(t1.starts), date(t1.ends) from t1
  where exists (select *
                from t2
                where (date(t2.starts) not between date(t1.starts) and date(t1.ends)) or 
                      (date(t2.ends) not between date(t1.starts) and date(t1.ends)) or
                      (date(t1.starts) not between date(t2.starts) and date(t2.ends))) ```
  </code></pre>