I want to search element inside JSONB in PostgreSQL here is my JSON
CREATE TABLE test
AS
SELECT jsondata::jsonb
FROM ( VALUES
( '{"key1": 1, "keyset": [10, 20, 30]}' ),
( '{"key1": 1, "keyset": [10, 20]}' ),
( '{"key1": 1, "keyset": [30]}' ),
( '{"key1": 1 }' ),
( '{"key1": 1, "key2": 1}' )
) AS t(jsondata);
in above table keyset not exist in all rows and my query is
SELECT * FROM test WHERE jsondata->>'keyset' = 10;
above query is giving empty result, and expected output is
jsondata
------------------------------------
{"key1": 1, "keyset": [10, 20, 30]}
{"key1": 1, "keyset": [10, 20]}