pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: terry@ashtonwoodshomes.com
To: 'Jeremy Semeiks' <jrs@denny.farviolet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Trying to make efficient "all vendors who can provide all items"
Date: Mon, 8 Mar 2004 14:23:02 -0500
Message-ID: <009e01c40542$c6d14380$2766f30a@development.greatgulfhomes.com> (raw)
In-Reply-To: <20040308190725.GH588@64.81.242.180>

Thanks for your response.

If I understand your proposal, it is a way of getting vendors who can
provide me with all the items in the items table.

But the situation I have is items table could have 100k items, and I want
all vendors who can provide a specific list of say 20 items.

Do I misunderstand your query?

Terry Fielder
Manager Software Development and Deployment
Great Gulf Homes / Ashton Woods Homes
terry@greatgulfhomes.com
Fax: (416) 441-9085


> -----Original Message-----
> From: Jeremy Semeiks [mailto:jrs@denny.farviolet.com]
> Sent: Monday, March 08, 2004 2:07 PM
> To: terry@ashtonwoodshomes.com
> Cc: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Trying to make efficient "all vendors who
> can provide
> all items"
>
>
> On Mon, Mar 08, 2004 at 11:02:13AM -0500,
> terry@ashtonwoodshomes.com wrote:
> > My mind is drawing a blank.  Please consider:
> > TABLE 1: items: list of items in catalog
> > item_id  |  item_description
> >
> > TABLE 2: vendors: list of vendors who provide 1 or more items
> > vendor_id |  vendor_name
> >
> > TABLE 3: item_vendors: record existence indicates vendor
> can provide item
> > item_id  |  vendor_id
> >
> >
> > QUESTION:
> > I have a list of say 5 items, and I want to find all
> vendors who can provide
> > ALL 5 items
> [...]
> > Yep, both my solutions are pretty ugly, especially in
> situations where my
> > list of items that need to be provided grow large.
> >
> > There must be a better way.  Can anyone help me with this?
>
> You could use some subselects:
>
> select vendor_id from
> (select vendor_id, count(*) as ct from item_vendors group by
> vendor_id) vict
> where ct = (select count(*) from items);
>
> I haven't tested this.
>
> - Jeremy
>




view thread (7+ messages)  latest in thread

Message-ID: <009e01c40542$c6d14380$2766f30a@development.greatgulfhomes.com>
Permalink:  ../009e01c40542$c6d14380$2766f30a@development.greatgulfhomes.com/
Also on:    postgresql.org/message-id/009e01c40542$c6d14380$2766f30a@development.greatgulfhomes.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: terry@ashtonwoodshomes.com, jrs@denny.farviolet.com
  Subject: Re: Trying to make efficient "all vendors who can provide all items"
  In-Reply-To: <009e01c40542$c6d14380$2766f30a@development.greatgulfhomes.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox