2 ms·
What if you only want the id and markup of each post? Postgres 9.4 gave us json_build_object: SELECT u.name, array_agg( json_build_o
by danneu 12y ago
What if you only want the id and markup of each post?
Postgres 9.4 gave us json_build_object:
SELECT
u.name,
array_agg(
json_build_object(
'id', p.id,
'markup', p.markup
)
) posts
FROM users u, posts p
WHERE p.user_id = u.user_id
GROUP BY u.user_id;