0

I have a table looking like:

Table_A

| name | email_addresses                                 |
| a    | ['[email protected]']                               |
| b    | ['[email protected]', '[email protected]']             |
| c    | ['[email protected]', '[email protected]']         |
| d    | ['[email protected]', '[email protected]', '[email protected]'] |

The field type of email_addresses is JSONB

In simple SQL, my query is like:

select * from Table_A where email_addresses = ['[email protected]', '[email protected]'] 

Which result should be : a, c, d

But not sure how to build this query in postgress json

1 Answer 1

1

You can use the ?| operator to compare the value of your array with the json field

select * from my_table where email_addresses::jsonb ?| array['[email protected]', '[email protected]'];

DBfiddle Deme

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.