title: SQL Select Newest Records based on Duplicate Records
body: <p>I have 2 Tables, wp_events and wp_merchants. </p>
  
  <p>I have many duplicated rows in the wp_events table, the only difference is the column uploaddate(TIMESTAMP) of when the record was added to the database.  I need an SQL statement that selects the prices from the wp_events table but if there are duplicates select the most recent. </p>
  
  <p>This is what I have so far but not all records are selected. </p>
  
  <pre><code>SELECT e1.merchant, e1.price, e1.url, wp_merchants.merchant_logo, wp_merchants.merchant_name, e1.eventname
  FROM wp_merchants, wp_events e1
  LEFT JOIN wp_events e2 ON ( e1.merchant = e2.merchant
  AND e1.uploaddate &lt; e2.uploaddate ) 
  WHERE e2.merchant IS NULL 
  AND wp_merchants.merchant_name = e1.merchant
  ORDER BY price ASC
  </code></pre>
  
  <p>PLEASE SEE <a href="http://sqlfiddle.com/#!2/1db0e/1" rel="nofollow">http://sqlfiddle.com/#!2/1db0e/1</a>      </p>