-- add some more data for testing
INSERT INTO some_data
VALUES ('departement=>bla,access=>bla'),
('departement=>it,access=>bla'),
('departement=>it,access=>login');
WITH condition_elements (... likeas above ...)
SELECT data,*
key FROM (
SELECT data, bool_and(data->key=ANY(value)) AS full_match
FROM some_data, condition_elements
WHERE GROUP BY data->key=ANY(value
); t
WHERE full_match;
data │ key data │ value │ full_match
──────────────────┼────────┼────────────────────────────────────────────────────────────────┼────────────
"access"=>"user""access"=>"login", "departement"=>"it" │ accesst
"access"=>"user" │ {superuser,user,login}t