<p>Using <code>MySQL</code>, I can do something like:</p>

<pre><code>SELECT hobbies FROM peoples_hobbies WHERE person_id = 5;
</code></pre>

<p><strong>My Output:</strong></p>

<pre><code>shopping
fishing
coding
</code></pre>

<p>but instead I just want 1 row, 1 col:</p>

<p><strong>Expected Output:</strong></p>

<pre><code>shopping, fishing, coding
</code></pre>

<p>The reason is that I'm selecting multiple values from multiple tables, and after all the joins I've got a lot more rows than I'd like.</p>

<p>I've looked for a function on <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws" rel="noreferrer">MySQL Doc</a> and it doesn't look like the <code>CONCAT</code> or <code>CONCAT_WS</code> functions accept result sets.</p>

<p>So does anyone here know how to do this?</p>

You can use
```
GROUP_CONCAT
```
:
```
```
SELECT person_id,
   GROUP_CONCAT(hobbies SEPARATOR ', ')
FROM peoples_hobbies
GROUP BY person_id;
```
```
As Ludwig stated in
his comment,
you can add the
```
DISTINCT
```
operator to avoid duplicates:
```
```
SELECT person_id,
   GROUP_CONCAT(DISTINCT hobbies SEPARATOR ', ')
FROM peoples_hobbies
GROUP BY person_id;
```
```
As Jan stated in
their comment,
you can also sort the values before imploding it using
```
ORDER BY
```
:
```
```
SELECT person_id, 
       GROUP_CONCAT(hobbies ORDER BY hobbies ASC SEPARATOR ', ')
FROM peoples_hobbies
GROUP BY person_id;
```
```
As Dag stated in
his comment,
there is a 1024 byte limit on the result. To solve this, run this query before your query:
```
```
SET group_concat_max_len = 2048;
```
```
Of course, you can change
```
2048
```
according to your needs. To calculate and assign the value:
```
```
SET group_concat_max_len = CAST(
                     (SELECT SUM(LENGTH(hobbies)) + COUNT(*) * LENGTH(', ')
                           FROM peoples_hobbies
                           GROUP BY person_id) AS UNSIGNED);
```
```