need assistance with multi-row matching expression

From: Mark Stosberg <mark(at)summersault(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: need assistance with multi-row matching expression
Date: 2002-08-19 15:21:10
Message-ID: Pine.BSF.4.44.0208191013320.75440-100000@nollie.summersault.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Hello,

I'm using Postgres 7.1 and have been enjoying the upgraded "sub-select"
support in this release versus older versions.

At the moment, I'm stuck with a SQL issue that I haven't run into
before.

I need to select the data for all the "parks" that match some search
criteria. The parks are stored in a "parks" table with a park_id as a
primary key.

Part of the search includes the logic of "match parks that include all
these features". The "features" are stored in their own table, and are
related to the parks table with a park_feature_map table, which contains
a park_id column and a feature_id column.

A user can use 0 to N to features, and each park might have 0 to N
entries in the park_feature_map table.

Where I'm stuck is that I'm used to putting together SQL statements to
match a given row. This is different-- to create a successful match for
a park_id, I need to check to match against N rows, where N is the
number of feature_ids provided.

How do I do that? Can I do it in one query?

Thanks!

-mark

http://mark.stosberg.com/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Fritz Lehmann-Grube 2002-08-19 15:22:02 Re: recursive function returning "setof"
Previous Message Christopher Kings-Lynne 2002-08-19 14:52:22 Re: recursive function returning "setof"