title: Delete duplicate order ids by keeping the tracking status - mysql
body: <p>I have a table called tracking_history. In this table parcel tracking history will be stored. For some reasons when ever the checkTrackStatus function executed all the existing tracking statuses are inserting repeatedly in the table. Here are the tracking statuses sequence. <code>'ACCEPTED','AT_SENDING_DEPOT','ON_THE_ROAD','AT_DELIVERY_DEPOT','DELIVERED'</code>
  I am saving the tracking id , order id also in that table. So I need to have for every order id the latest tracking status should be there (<code>'ACCEPTED','AT_SENDING_DEPOT','ON_THE_ROAD','AT_DELIVERY_DEPOT','DELIVERED'</code>) and remaining duplicate values should be removed. I tried with the below query.</p>
  <pre><code>`DELETE t1 FROM tracking_history t1, tracking_history t2 
  WHERE t1.id &lt; t2.id AND t1.order_id = t2.order_id` 
  </code></pre>
  <p>But this query is keeping only latest records and removing remaining all other.
  <code>Means I am  having all orders ids with DELIVERED Status only.</code> How can I achieve to remove duplicate statuses by keeping the latest statuses ? Any help would be greatly appreciated.</p>