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?
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?
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 employGROUP 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.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.