问题
Is it possible to select the concatenation of all the results returned by a subquery?
So if the subquery returns more than one row, I can somehow get all the results contained in a single string?
回答1:
Sort of. What you can get is the concatenated result of all the rows that were grouped together using GROUP_CONCAT. You could use that to employ GROUP BY
by a column that you know would group the result set correctly and then using the function to return the concated groups. The manual page should provide some examples.
回答2:
Some MySQL clients, such as the MySQL Command-Line tool, can export the result set in various formats, such as XML.
If you're using a programming language that implements the MySQL client/server protocol through some type of API, it seems like building the array would be trivial in code. PHP's MySQL API returns results in an array.
If you're talking about grouping multiple rows in a result set into a single row, then take a look at GROUP_CONCAT.
来源:https://stackoverflow.com/questions/9024248/mysql-arrays-can-this-be-done