title: Mysql Inner Join and Group By repeating row
body: <p>I have problem with that more comments the comment table has. Then the more the <code>User</code> table repeating it value in the report group. It should only fetch user once, while comments as many there is which it is the current behaviour. But I would like the user being fetched once.</p>
  <p>How it's now:</p>
  <pre><code>[&quot;text&quot;: &quot;My first report&quot;,
  user: [{&quot;display_name&quot;: &quot;Cyclops&quot;, &quot;photo_url&quot;: &quot;CYCLOPS_IMAGE.png&quot;,
  {&quot;display_name&quot;: &quot;Cyclops&quot;, &quot;photo_url&quot;: &quot;CYCLOPS_IMAGE.png&quot;},
  {&quot;display_name&quot;: &quot;Cyclops&quot;, &quot;photo_url&quot;: &quot;CYCLOPS_IMAGE.png&quot;}}],
  comments: [{&quot;text&quot;: &quot;Great Report&quot;, display_name: &quot;Xavier&quot;},
  {&quot;text&quot;: &quot;Bad Report&quot;, display_name: &quot;Logan&quot;},
  {&quot;text&quot;: &quot;Thanks for the feedback&quot;, display_name: &quot;Cyclops&quot;}]]
  </code></pre>
  <p>What i expect:</p>
  <pre><code>[&quot;text&quot;: &quot;My first report&quot;,
  user: [{&quot;display_name&quot;: &quot;Cyclops&quot;, &quot;photo_url&quot;: &quot;CYCLOPS_IMAGE.png&quot;}],
  comments: [{&quot;text&quot;: &quot;Great Report&quot;, display_name: &quot;Xavier&quot;},
  {&quot;text&quot;: &quot;Bad Report&quot;, display_name: &quot;Logan&quot;},
  {&quot;text&quot;: &quot;Thanks for the feedback&quot;, display_name: &quot;Cyclops&quot;}]]
  </code></pre>
  <p>Code:</p>
  <pre><code>SELECT report.text, 
         Json_arrayagg(Json_object('display_name', users.display_name, 'photo_url', users.photo_url)) AS USER, 
         Json_arrayagg(Json_object('text', report_comments.text, 'display_name', report_comments.user_id)) AS COMMENTS 
  FROM   report 
         INNER JOIN users 
                 ON users.id = report.user_id 
         LEFT JOIN report_comments 
                ON report_comments.report_id = report.id 
  WHERE  report.user_id = :userId 
  GROUP  BY report.id 
  </code></pre>