0

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" ]
Răzvan Flavius Panda
  • 21,136
  • 15
  • 108
  • 159

1 Answers1

3
create table example ( value text );
insert into example values ('value1'), ('value2'), ('value3');
select json_agg(value) from example;
            json_agg            
────────────────────────────────
 ["value1", "value2", "value3"]