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

From Mark Stosberg
Subject Re: need assistance with multi-row matching expression
Date
Msg-id Pine.BSF.4.44.0208191206040.75440-100000@nollie.summersault.com
Whole thread Raw
In response to Re: need assistance with multi-row matching expression  ("Nick Fankhauser" <nickf@ontko.com>)
List pgsql-sql
On Mon, 19 Aug 2002, Nick Fankhauser wrote:
>
> This may not be the best way, but I couldn't resist taking a shot at it...

Thanks for the response Nick. If only I knew I was going to get a
response from a block away, I would have just come down to say hi. :)

I had an "a ha" moment about this over lunch. I was making the problem
much harder than it needed to me, having assured myself I was going to
need some advanced SQL feature to solve the  problem. Some testing seems to
reveal that I can address this problem simply by joining against the
park_feature_map table N times. This way I only need to match against 1
row each of these tables, which is easy in SQL. Here's my statement I
tested with for N=2:

SELECT p.park_id, park_name   FROM parks p   JOIN park_feature_map map_4       ON (p.park_id = map_4.park_id AND
map_4.feature_id=4)  JOIN park_feature_map map_15       ON (p.park_id = map_15.park_id AND map_15.feature_id=15);
 

In this way, I'm only returned the parks that match all the features.
Thanks again for your help!
  -mark

http://mark.stosberg.com/



pgsql-sql by date:

Previous
From: "Nick Fankhauser"
Date:
Subject: Re: need assistance with multi-row matching expression
Next
From: "Darrin Domoney"
Date:
Subject: Urgent - SQL Unique constraint error (long)