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
CodePudding user response:
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]'];