1

I have options JSONB field:

enter image description here

And I can get JSONB array:

SELECT "options" FROM "products";

->

'[["black", "2"], ["white", "7"]]'::JSONB

But, How can I make array of arrays?

->

ARRAY[ARRAY['black', '2'], ARRAY['white', '7']]

1 Answer 1

1
select (
  select array_agg(
    (select array_agg(s) from jsonb_array_elements_text(a) j2(s))
  ) from jsonb_array_elements(options) j1(a)
) from products
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.