Searching for results with an unknown amount of data

From: "Oz" <x_download(at)hotmail(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Searching for results with an unknown amount of data
Date: 2005-09-02 21:27:07
Message-ID: BAY101-DAV1617F72B18EE9D28B97922FCA30@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I've got two tables, A and B, the first one containing columns

A_ID | info

where A_ID is primary, so that this table stores various information about
an object, and the second containing columns

A_ID | property

where property is an integer referring to a particular property that an
object may possess. I've seperated these into two tables so that an object
may have several (ie an unknown number of) properties.

Now, I want to find all objects that have at most properties 1,2,3, say (so
something with (1,2) is okay, as is (1,2,3)). I can't see a way to do this
-- can anyone help?
Also, what if I want to find all the objects possessing properties 4,5,6, as
well as possibly other things? I've done it with nested SELECTs (constructed
programmatically), but I think this is quite slow and not a very pleasing
solution.

Obviously, both these things will need to be done for an arbitrary list of
integers.

Thanks,
DL

Browse pgsql-sql by date

  From Date Subject
Next Message Julian Scarfe 2005-09-03 14:59:18 Re: Negative lookbehind assertions in regexs
Previous Message Philip Hallstrom 2005-09-02 21:00:59 Re: insert only if conditions are met?