Multiple IN

From: Leandro Fanzone <leandro(at)hasar(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Multiple IN
Date: 2001-12-11 15:43:08
Message-ID: 3C16298C.A6204AD1@hasar.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Maybe this is a silly question. I have a table t with two fields f1 and
f2. Those fields together form the primary key. I want to select a list
of pairs from that table. The simplest SQL clause would be

SELECT * FROM t WHERE (f1 = v1 AND f2 = v2) OR (f1 = v3 AND f2 = v4)
...;

When that list is long, on the one hand I suppose it won't have a good
performance; on the other, the resultant clause is clumsy and too long.
Is there any other (more elegant) solution for this? If the field would
be just one, a simple IN would do better, but as far as I know there is
no IN for multiple fields.
Thank you in advance.

Leandro Fanzone

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2001-12-11 16:30:57 Re: Multiple IN
Previous Message Duncan Adams (DNS) 2001-12-11 10:31:30 Re: sql help