common table expression - SQLite Concatenating Column values -
there similar answers other database types haven't found example sqlite, i've included answer came with. the problem given table following ╔══════════╦══════╗ ║ item ║ tag ║ ╠══════════╬══════╣ ║ "item1" ║ "a" ║ ║ "item1" ║ "b" ║ ║ "item1" ║ "c" ║ ║ "item2" ║ "a" ║ ║ "item1" ║ "d" ║ ║ "item2" ║ "f" ║ ║ "item1" ║ "e" ║ ╚══════════╩══════╝ create output of: ╔═══════════╦═════════════╗ ║ item ║ tags ║ ╠═══════════╬═════════════╣ ║ "item1" ║ "a,b,c,d,e" ║ ║ "item2" ║ "a,f" ║ ╚═══════════╩═════════════╝ that's group_concat() for: select item, group_concat(tag) tags (select item, tag t order item, tag) group item;