title: MySQL INNER JOIN select only one row from second table
body: <p>I have a <code>users</code> table and a <code>payments</code> table, for each user, those of which have payments, may have multiple associated payments in the <code>payments</code> table. I would like to select all users who have payments, but only select their latest payment. I'm trying this SQL but i've never tried nested SQL statements before so I want to know what i'm doing wrong. Appreciate the help</p>
  
  <pre><code>SELECT u.* 
  FROM users AS u
      INNER JOIN (
          SELECT p.*
          FROM payments AS p
          ORDER BY date DESC
          LIMIT 1
      )
      ON p.user_id = u.id
  WHERE u.package = 1
  </code></pre>