title: MySQL: Not unique table/alias: 'favourites'
body: <p>The error I'm getting is:</p>
  
  <blockquote>
    <p>Not unique table/alias: 'favourites'</p>
  </blockquote>
  
  <p>I apologise for the reasonably intense query(!):</p>
  
  <pre><code>    SELECT code.id AS codeid, code.featured AS featured, code.title AS codetitle, code.summary AS codesummary, code.author AS codeauthor, code.date, code.challengeid,
      ratingItems.*, FORMAT((ratingItems.totalPoints / ratingItems.totalVotes), 1) AS rating,
      code_tags.*, tags.*,
      users.firstname AS authorname, users.id AS authorid,
      GROUP_CONCAT(tags.tag SEPARATOR ', ') AS taggroup,
      COUNT(DISTINCT comments.codeid) AS commentcount,
      favourites.id, favourites.code_id, favourites.user_id
  
      FROM (code)
      JOIN code_tags ON code_tags.code_id = code.id
      JOIN tags ON tags.id = code_tags.tag_id
      JOIN users ON users.id = code.author
      LEFT JOIN comments ON comments.codeid = code.id
      LEFT JOIN ratingItems ON uniqueName = code.id
      LEFT JOIN favourites ON favourites.user_id = 10
      LEFT JOIN favourites ON favourites.code_id = code.id
  
      GROUP BY code_id
      ORDER BY date desc
  </code></pre>
  
  <p>What am I doing wrong? I really can't understand it...</p>
  
  <p>Thanks!</p>
  
  <p>Jack</p>