need assistance with multi-row matching expression - Mailing list pgsql-sql

From Mark Stosberg
Subject need assistance with multi-row matching expression
Date
Msg-id Pine.BSF.4.44.0208191013320.75440-100000@nollie.summersault.com
Whole thread Raw
Responses Re: need assistance with multi-row matching expression  ("Nick Fankhauser" <nickf@ontko.com>)
List 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/



pgsql-sql by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: Re: recursive function returning "setof"
Next
From: Fritz Lehmann-Grube
Date:
Subject: Re: recursive function returning "setof"