Is there a MySQL equivalent for PostgreSQL array_to_string

I am trying to find the MySQL equivalent of the PostgreSQL array and array_to_string functions and stumbled upon this post but ask about oracle9i, which does not help me. I need to achieve this using MySQL, but even Google cannot find suitable answers.

So you do not need to read two entries, here is a repeat of the question:

In PostgreSQL, using the array and array_to_string functions, you can do the following:

Given the people table:

id | name --------- 1 | bob 2 | alice 3 | jon 

SQL:

 SELECT array_to_string(array(SELECT name FROM people), ',') AS names; 

Will return:

 names ------------- bob,alice,jon 

Anyone have any ideas how to achieve this in MySQL?

+3
source share
1 answer

Try GROUP_CONCAT . eg:

 SELECT GROUP_CONCAT(name) AS names FROM people GROUP BY id; 
+6
source

All Articles