0

version = 9.5.5

Now I have a column named info, like this:

[{"id":1, "name":"car"},{"id":2, "name":"bus"}]

I want to remove {"id":2, "name":"bus"} which id = 2, instead of info::jsonb - 1,not by index but the key-value, so how can I do that? thanks

1 Answer 1

1
select jsonb_agg(e.value) from (
    select '[{"id":1, "name":"car"},{"id":2, "name":"bus"}]'::jsonb as data
) a, jsonb_array_elements(a.data) e
where e.value->>'id' <> '2'
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.