Having a table named Example
with a column named Value
and some example data in it value1
, value2
, value3
.
How can I select the values in the table into a JSON array?
[ "value1", "value2", "value3" ]
Having a table named Example
with a column named Value
and some example data in it value1
, value2
, value3
.
How can I select the values in the table into a JSON array?
[ "value1", "value2", "value3" ]
create table example ( value text );
insert into example values ('value1'), ('value2'), ('value3');
select json_agg(value) from example;
json_agg
────────────────────────────────
["value1", "value2", "value3"]