(have done this before, but memory fades, as does goggle)
wish to get select from users
with the tag.tag_id
s for each user returned as an array.
select usr_id, name, (select t.tag_id from tags t where t.usr_id = u.usr_id) as tag_arr from users u;
with the idea embedded query tag_arr
would be an array
Use the aggregate function:
or an array constructor from the results of a subquery:
The second option is simple and fast while the first one is more general, e.g. in cases when you need to use more than one aggregates.