Perhaps [group_concat aggregate function](https://www.sqlite.org/lang_aggfunc.html#groupconcat) is just the thing.