title: MySQL: Join Tables But Remove Oldest Entries for Matching Field
body: <p>I have two separate tables with the following data. I know finding the elements with the max value in a field is a common question, but I haven't found a way to do this in my situation where the data is spread over two tables.</p>
  
  <p>Enrollment Table:</p>
  
  <pre><code>StudentID CourseID Section_Key Date_Added
  </code></pre>
  
  <p>Section Table:</p>
  
  <pre><code>SectionID Period
  </code></pre>
  
  <p>What I'm trying to do is show an entire student's schedule, but remove older courses that have been dropped. The Enrollment table includes courses that have been dropped so I want to only show the most recently added course for each Period.</p>
  
  <p>For example, say there is a student with the following classes in their schedule:</p>
  
  <pre><code>CourseID Section_Key Period Date_Added
   2503F     123456      1     2018-05-13
   9990      245678      1     2018-08-01
  </code></pre>
  
  <p>I only want it to show the second course above in the results. I would also like the results sorted by Period.</p>