title: Mysql select oldest record for each user
body: <p>I'm trying to create a list in PHP of the oldest entries for each user in the database.</p>
  
  <pre><code>SELECT *, 
  MIN(`entries`.`entry_date`) 
  AS entry_date 
  FROM (`entries`) 
  JOIN `user_profiles` 
  ON `user_profiles`.`user_id` = `entries`.`user_id` 
  WHERE `status` = 1 
  GROUP BY `entries`.`user_id`
  </code></pre>
  
  <p>I'm using the query to retrieve from the <code>entries</code> table the oldest dated entry using <code>MIN()</code>and joining with table <code>user_profiles</code> for other data. The query should select the oldest entry for each user. It seems to work but it retrieves the wrong <code>entry_date</code> field on some entries when I echo them. Please help, I can't spot what I'm doing wrong..</p>