Re: Matching a large number of user chosen

From: Rob <rob(at)obsidian(dot)co(dot)za>
To: John Taylor <postgres(at)jtresponse(dot)co(dot)uk>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Matching a large number of user chosen
Date: 2002-04-12 16:11:24
Message-ID: Pine.LNX.4.33L2.0204121209580.18801-100000@Genesis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi John,

>
> I have an application where a user can choose a large number of distinct products to process.
>
> The SQL that I currently use looks something like this:
>
> select * from products where date='01012000' AND ( id='123' OR id='456' OR id='789' );
>
> There can be maybe hundreds of different unconnected id's chosen.
>
> Is there a more elegant/efficient way to do this than a large number of ORs ?

You could try

AND id in ('123','456','789');

--
Rob

He who dies with the most toys ...

... still dies

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message P. Jourdan 2002-04-13 14:08:41 migration still a problem
Previous Message Rob 2002-04-12 15:42:53 Update function