tags:

views:

190

answers:

1

Hi all,

I have a table containing countries:

id     country
------------
0     Monaco 
1     Mongolia
2     Montenegro
3     Morocco
4     Mozambique
5     Myanmar

I have a sub query that looks like this.

(SELECT country FROM COUNTRIES WHERE id < 10) AS ´Trip´

I want to have that subquery to be formatted as a string like this:

'Monaco, Mongolia, Montenegro, Morocco, Mozambique, Myanmar'

Is that possible?

+2  A: 

You can use the group_concat function:

SELECT group_concat(country, ', ') FROM countries WHERE id < 10
Lukáš Lalinský