title: MySQL: Finding duplicates based on multiple columns AND deleting the second occurrence of each
body: <p>Good morning.</p>
  
  <p>I currently have the following MySQL query that finds rows in a table that have identical values for "tutor", "startTime", "endTime", and "date":</p>
  
  <pre><code>select 
  tutor, 
  date, 
  startTime, 
  endTime, 
  count(*) cnt 
  from reservations 
  group by 
  date, 
  tutor,
  startTime, 
  endTime 
  having cnt&gt;1 
  order by cnt asc;
  </code></pre>
  
  <p>I would like to expand this query to delete all but the first occurrence of each of the duplicates.  </p>
  
  <p>In the table, the only difference between the two rows is a field called "appointmentID".  Therefore, the end result of the query should be that the first appointmentID row is kept while any subsequent duplicate rows are deleted.</p>
  
  <p>Is this possible?  I've searched here and through many other sites and, while I've found numerous examples for finding and deleting duplicates, none have dealt with doing so based on the values in several columns.</p>
  
  <p>Thanks so much!</p>
  
  <p>Richard</p>