Question

Anyone knows if String Aggregation in sqlite is possible? If i have an animal column with 5 rows/datas, how can i combine them so that the output would be in one field 'dog','cat','rat','mice','mouse' as animals

Thanks

Was it helpful?

Solution

You're looking for something like the following:

select group_concat(animal) from animals;

This will return something like the following:

dog,cat,rat,mice,mouse

If you don't want to use a comma as the separator, you can add your own separator as a second parameter:

select group_concat(animal, '_') from animals;

which will return:

dog_cat_rat_mice_mouse
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top