Skip to content
Advertisement

Postgresql – JSONB ARRAY – Obtaining results after manipulation as single JSON ARRAY

We are using postgresql 10.5. I have the following schema and data.

The above select query returns the email address correctly. However, it returns the result as 2 different rows. Is it possible to have the result in one row as json array instead? Or should I use only subquery to achieve this?

Advertisement

Answer

If you know there are only two addresses, you can access the array elements directly:

To get them as a JSON array, you could use a sub-select:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement