Self-Referencing - Mailing list pgsql-sql

From David Olbersen
Subject Self-Referencing
Date
Msg-id Pine.LNX.4.31.0103281532530.11993-100000@bubbles.electricutopia.net
Whole thread Raw
Responses Re: Self-Referencing  (Christof Glaser <gcg@gl.aser.de>)
Re: Self-Referencing  (Cedar Cox <cedarc@visionforisrael.com>)
List pgsql-sql
Hello,
 I have a feeling this isn't going to make much sense, but I'm gonig to try anyway.
 What I'd like to do is be able to refer to an outer-SELECT from an inner-SELECT. I hope this makes sense.
 I need to be able to refer to the row that's being processed in a SELECT. I'm going to use the idea of 'this'
referringto the row that's currently being processed. Here's the example of what I'd like:
 
 SELECT   building_id,   num_buildings,   (     SELECT count( building_id )     FROM   building_portals     WHERE
building_id= THIS.building_id   ) FROM buildings;
 
 Am I making things too complicated, and if so will somebody *PLEASE* tell me the easier way to do this. Thanks.

-- Dave



pgsql-sql by date:

Previous
From: "Marcos Minshew"
Date:
Subject: SELECT ... FOR UPDATE
Next
From: "Gerald Gutierrez"
Date:
Subject: Can a SELECT block?