title: MySQL: Duplicate values when joining from multiple tables
body: <p>I'm trying to get some news article from my database and also get the related items with it.
  The database structure looks like this:</p>
  
  <pre><code>news               (id, article        )
  newsItemsRelation  (id, newsId,  itemId)
  newsAuthorRelation (id, newsId,  userId)
  items              (id, itemTitle      )
  </code></pre>
  
  <p>Then I also have a table for the items and the users with their data.</p>
  
  <p>When I run the query below I get duplicates of the items if I have multiple authors for the same article and I get duplicate authors if I have multiple items for the same article.</p>
  
  <pre><code>SELECT
          article,
          GROUP_CONCAT(name) AS author,
          GROUP_CONCAT(itemTitle) AS item
      FROM news
      LEFT JOIN newsItemsRelation ON
          newsItemsRelation.newsId = news.id
      LEFT JOIN items ON
          items.id = newsItemsRelation.itemId
      LEFT JOIN newsAuthorsRelation ON
          newsAuthorsRelation.newsId = news.id
      LEFT JOIN profiles ON
          profiles.id = newsAuthorsRelation.userId
      GROUP BY news.id
  </code></pre>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>My result look like this:</p>
  
  <p>Article: Article goes here</p>
  
  <p>Author: Walter White, Dexter Morgan, Walter White, Dexter Morgan</p>
  
  <p>Item: Breaking Bad, Dexter, Breaking Bad, Dexter</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Doing <code>GROUP_CONCAT(DISTINCT name)</code> OR <code>GROUP_CONCAT(DISTINCT itemTitle)</code> doesn't solve my problem since multiple items can have the same itemTitle but different ids. Same goes for authors. That means that my result could look like "Dexter, Dexter", though now that looks like "Dexter, Dexter, Dexter, Dexter"</p>