pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Olbersen <dave@slickness.org>
To: pgsql-sql@postgresql.org
Subject: Self-Referencing
Date: Wed, 28 Mar 2001 15:38:38 -0800 (PST)
Message-ID: <Pine.LNX.4.31.0103281532530.11993-100000@bubbles.electricutopia.net> (raw)

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' referring to 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




view thread (3+ messages)  latest in thread

Message-ID: <Pine.LNX.4.31.0103281532530.11993-100000@bubbles.electricutopia.net>
Permalink:  ../Pine.LNX.4.31.0103281532530.11993-100000@bubbles.electricutopia.net/
Also on:    postgresql.org/message-id/Pine.LNX.4.31.0103281532530.11993-100000@bubbles.electricutopia.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: dave@slickness.org
  Subject: Re: Self-Referencing
  In-Reply-To: <Pine.LNX.4.31.0103281532530.11993-100000@bubbles.electricutopia.net>
  References: <Pine.LNX.4.31.0103281532530.11993-100000@bubbles.electricutopia.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox