select id,
json_query(json_data, '$[*]?(@.fruit == "apple")') as json_data
from t1;
ID JSON_DATA
---------- --------------------------------------------------------------------------------
1 {"fruit":"apple","quantity":10}
SQL>
select id,
json_query(json_data, '$[*]?(@.fruit in ($v1, $v2))'
passing 'apple' as "v1", 'orange' as "v2"
with wrapper) as json_data
from t1;
ID JSON_DATA
---------- --------------------------------------------------------------------------------
1 [{"fruit":"apple","quantity":10},{"fruit":"orange","quantity":12}]
SQL>
select id,
json_query(json_data, '$[*]?(@.fruit in ($v1, $v2) && @.quantity > $v3)'
passing 'apple' as "v1", 'orange' as "v2", 11 as "v3"
with wrapper) as json_data
from t1;
ID JSON_DATA
---------- --------------------------------------------------------------------------------
1 [{"fruit":"orange","quantity":12}]
SQL>
select id,
json_query(json_data, '$[*]?(@.fruit in ($v1, $v2) && @.quantity > $v3).quantity'
passing 'apple' as "v1", 'orange' as "v2", 11 as "v3"
with wrapper) as json_data
from t1;
ID JSON_DATA
---------- --------------------------------------------------------------------------------
1 [12]
SQL>
select id,
json_query(json_data, '$[*]?(@.fruit in ($v1, $v2)).quantity?(@ > $v3)'
passing 'apple' as "v1", 'orange' as "v2", 11 as "v3"
with wrapper) as json_data
from t1;
ID JSON_DATA
---------- --------------------------------------------------------------------------------
1 [12]
SQL>