title: Use a GROUP_CONCAT and JOIN in a subquery
body: <p>I have a DB under MySQL with one main table with unique id, few tables that list different choices (with one id column, one text column to describe the item). So, for one record in the main table, I can have multiple choices associated to the choice table.<br>
  I'd like to create a View where all information could be visible, using GROUP_CONCAT to concatenate into one field the different choices from a given 'choice' table. However, my query repeats many times each list of choices when the record is related to other multiple choices from another 'choice' table. The query returns all the possible combinations between those choices... <br>
  Here my query (reduced to 2 'choice' tables -t_age, t_animal- for the example)<br></p>
  
  <pre><code>SELECT general.id_g,
      GROUP_CONCAT(CAST(t_age AS CHAR) SEPARATOR ', ') AS age,
      GROUP_CONCAT(CAST(t_animal AS CHAR) SEPARATOR ', ') AS animal
  FROM general
  LEFT JOIN  interm_age 
      INNER JOIN t_age ON interm_age.id_age = t_age.id_age
  ON general.id_g = interm_age.id_g  
  LEFT JOIN  interm_animal 
      INNER JOIN t_animal ON interm_animal.id_animal = t_animal.id_animal
  ON general.id_g = interm_animal.id_g
  GROUP BY id_g;
  </code></pre>
  
  <p>I tried to include each CONCAT/JOIN within a subquery into a main SELECT as followed, but MySQL tells me "returns more than 1row", which is the case indeed. And?</p>
  
  <pre><code>SELECT id_g, (
      SELECT GROUP_CONCAT(CAST(t_age AS CHAR) SEPARATOR ', ')
      FROM general
      LEFT JOIN  interm_age 
      INNER JOIN t_age ON interm_age.id_age = t_age.id_age
      ON general.id_g = interm_age.id_g  
      GROUP BY general.id_g  )
  FROM general;
  </code></pre>
  
  <p><br>
  [EDIT]
  In more details, this is my DB (with FK)<br><br>
  general<br>
  -----------<br></p>
  
  <pre><code>id_g  |  date
  902   |    2016/01/01
  956   |    2016/02/01
  959   |    2016/02/01
  </code></pre>
  
  <p><br></p>
  
  <p>interm_age<br>
  -----------<br></p>
  
  <pre><code>id_age  | id_g
  1       |     902
  3       |     902
  1       |     956
  4       |     956
  </code></pre>
  
  <p><br>
  interm_animal<br>
  -----------<br></p>
  
  <pre><code>id_animal  |     id_g
  1          |     902
  5          |     902
  5          |     959
  7          |     959
  </code></pre>
  
  <p><br>
  t_age<br>
  -----------<br></p>
  
  <pre><code>id_age  |     age
  1       |     &lt;10y
  3       |     &gt;10y
  4       |     &gt;60y
  </code></pre>
  
  <p><br>
  t_animal<br>
  -----------<br></p>
  
  <pre><code>id_animal  | animal
  1          |    bird
  5          |     mammal
  7          |     insect
  </code></pre>
  
  <p><br></p>
  
  <p>And I would like something like :<br></p>
  
  <pre><code>id_g | date       | age        | animal
  902  | 2016/01/01 | &lt;10y, &gt;10y | bird, mammal
  </code></pre>
  
  <p>and so on...</p>
  
  <p>Thanks in advance!</p>