0

I have a table with a JSONB column which stores some structure as below: [{ "id": "id1", "value": "value1" }, { "id": "id2", "value": "value2" }, { "id": "id3", "value": "value3" }]

I want to query the jsonb field by providing more than one values for the "value" field like in a OR condition.

Currently i have the query running for a single value in the where clause and i have to run it in a loop from the persistence layer and then merge the results. This is what i am using:

select * 
from table1 
where lower(column1::text)::jsonb @> cast(lower('[{"value":"value1"}]'::text) AS JSONB)

Is there a way i can pass multiple values and the result will be an OR for more than one values passed.

klin
  • 112,967
  • 15
  • 204
  • 232
Priyabrat Nanda
  • 1,095
  • 3
  • 18
  • 34
  • Today I answered something like that: [https://stackoverflow.com/questions/49772005/postgresql-get-parent-categories-from-table/49782552#49782552](https://stackoverflow.com/questions/49772005/postgresql-get-parent-categories-from-table/49782552#49782552) Perhaps you can use something like that. – Dan Apr 12 '18 at 21:36
  • Anyway, it would be great if you add to your question the Output you are looking for or an example of what you are trying to achieve – Dan Apr 12 '18 at 21:39

0 Answers0