title: MySQL Not unique table/alias
body: <p>I looked at the answers of others having the same problem, but I can't figure out how to fix the "Not unique table/alias".</p>
  
  <pre><code>SELECT m.*, u.*
    FROM ".TABLE_PREFIX."users_medals u
    LEFT JOIN ".TABLE_PREFIX."medals m ON u.medal_id = m.medal_id
    WHERE u.user_id IN (".$post['uid'].")
    AND m.medal_level = (
      SELECT MAX(".TABLE_PREFIX."medals.medal_level) FROM ".TABLE_PREFIX."medals
      LEFT JOIN ".TABLE_PREFIX."medals ON ".TABLE_PREFIX."users_medals.medal_id = ".TABLE_PREFIX."medals.medal_id
      WHERE ".TABLE_PREFIX."users_medals.user_id = u.user_id
      AND ".TABLE_PREFIX."medals.medal_type = m.medal_type
    )
  </code></pre>
  
  <p><code>TABLE_PREFIX</code> is what my script uses to define the database table prefix.</p>