Using contains operator on arrays that have duplicate elements: feedback request.

From: Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)com>
To: PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Using contains operator on arrays that have duplicate elements: feedback request.
Date: 2012-08-08 14:34:41
Message-ID: CA+4Thdrj49+G30xwbK3zZddDvR0syRuW+g0ckZT+-gCo=ecM0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

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