views:

64

answers:

3

Say, there are 2 tables:

Person
| id | name |

LanguagesSpoken
| person_id | language_name |

Is there a way to create a view that would contain 2 columns: person_name and languages_spoken as a comma-separated list?

I'm developing against SQLite.

+1  A: 
select name, group_concat(language_name) as languages
from person p inner join languagesSpoken l
on p.id = l.person_id
group by l.person.id
davek
+2  A: 

Use:

  SELECT p.name,
         GROUP_CONCAT(ls.language_name, ',')
    FROM PERSON p
    JOIN LANGUAGESSPOKEN ls ON ls.personid = p.personid
GROUP BY p.name

Reference: SQLite aggregate functions

OMG Ponies
+1  A: 

group_concat() is your answer.

Seva Alekseyev