Using contains operator on arrays that have duplicate elements: feedback request. - Mailing list pgsql-general

From Seref Arikan
Subject Using contains operator on arrays that have duplicate elements: feedback request.
Date
Msg-id CA+4Thdrj49+G30xwbK3zZddDvR0syRuW+g0ckZT+-gCo=ecM0Q@mail.gmail.com
Whole thread Raw
Responses Re: Using contains operator on arrays that have duplicate elements: feedback request.  ("David Johnston" <polobo@yahoo.com>)
List pgsql-general
Greetings,
I've been trying to use contains operator on an array such as {3,4,9,4,5}
My problem is, I'd like to get rows that has two 4s in them, and contains operator seems to work separately for each member of the right operand. Therefore

select  '{3,4,9,4,5}'::int[] @> '{4,4,4}'

returns true. I'm trying to implement the semantics of the operation so that the set {4,4,4} is a single parameter to a subset query, which should return false in the case above.

Is there any way I can force the contains operation to consider cardinality of unique members of the set ? Arrays look like to simplest way of performing set operations on a group of values, but is there anything else that can be an alternative to them?

Best regards
Seref



pgsql-general by date:

Previous
From: Michael Trausch
Date:
Subject: Fwd: Re: Interval "1 month" is equals to interval "30 days" - WHY?
Next
From: "David Johnston"
Date:
Subject: Re: Using contains operator on arrays that have duplicate elements: feedback request.