Is there a MySQL equivalent to PostgreSQL array_to_string
I'm trying to find the MySQL equivalent of the PostgreSQL functions array and array_to_string and came across this post but asking for oracle9i which doesn't help me. I need to achieve this with MySQL but even Google can't seem to find any suitable answers.
So you don't have to read two posts, here is a repeat of the question:
In PostgreSQL, using the array and array_to_string functions can do the following:
Given the table "people&开发者_如何学Goquot;:
id | name --------- 1 | bob 2 | alice 3 | jon
The 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?
Try GROUP_CONCAT . e.g:
SELECT GROUP_CONCAT(name) AS names FROM people GROUP BY id;
精彩评论