title: mysql select closest result from todays date past/future
body: <p>I am sure this is a common task although all of the examples I have looked at dont help me solve this issue. </p>
  
  <p>I have 2 tables:</p>
  
  <blockquote>
    <ol>
    <li><code>events</code></li>
    <li><code>schedules</code> with foreign key to events. With <code>schedule_datetime_from</code> and <code>schedule_datetime_until</code></li>
    </ol>
  </blockquote>
  
  <p>Q. When selecting all of the events, how would I also fetch/join the first closest schedule based on todays date? E.g only return the most relevant schedule.</p>
  
  <p>NOTE: There maybe more than one schedule for each event. The schedule may also be in the past.  </p>
  
  <p>E.g <code>e.schedule_datetime_from &gt;= NOW() OR schedule_datetime_until &gt; NOW()</code> would return only the future schedules, but how do I also return schedules in the past. Or do I need to use a ORDER BY + LIMIT 1 to achieve this?</p>