Previously i try to use overlap to find data where data has any of values in array. I use postgres
SQL statement was:
SELECT *,
ARRAY_AGG("reserve"."state_id" ) AS "states"
FROM "orders_order"
JOIN "reserve" ON ("order"."id" = "reserve"."order_id")
GROUP BY "order"."id"
HAVING (ARRAY_AGG("reserve"."state_id" )&& array['test', 'test_new']::varchar(255)[])
For example if my states where like below:
{'test', 'new_test' }
It gives me all reserves if states test was in array
Now i need receive states if only ['test'] in array
Expected output must be empty in above mentioned example
Some examples to clarify:
1. {'test', 'new_test' } -> false
2. {'test', 'test' } -> true
3. {'test'} -> true
How can i achieve this. What needs to add to my SQL statement?