From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jens Hartwig <jhartwig@debis.com>
Cc: Tod McQuillin <devin@spamcop.net>
Cc: Nikolaj Lundsgaard <Nikolaj@konfus.dk>
Cc: pgsql-sql@postgresql.org
Subject: Re: Sv: how to build this query ??? Please help !!!
Date: Thu, 04 Jan 2001 04:46:27 -0500
Message-ID: <21122.978601587@sss.pgh.pa.us> (raw)
In-Reply-To: <3A543766.B66B482C@debis.com>
References: <Pine.GSO.4.31.0101040151430.3519-100000@sysadmin>
<3A543766.B66B482C@debis.com>
Jens Hartwig <jhartwig@debis.com> writes:
> I have never seen a statement like
> SELECT a, (SELECT b)
> FROM xyz;
> IMHO this is no normal subselect and it does not correlate with the
> SQL-standard. Is it a trick?
I think it's OK (we're assuming that a and b are columns of xyz, right?)
The inner select sees values from the outer select as constants. This
is not really different from
SELECT x FROM xyz WHERE y IN
(SELECT a FROM abc WHERE b = xyz.z);
where the inner WHERE relies upon an outer reference to the current
xyz tuple.
It is true that "SELECT b" isn't a valid SQL92 SELECT because it
hasn't got a FROM clause, but that's a minor quibble that just about
every vendor has invented a workaround for.
regards, tom lane
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: tgl@sss.pgh.pa.us, jhartwig@debis.com, devin@spamcop.net, Nikolaj@konfus.dk
Subject: Re: how to build this query ??? Please help !!!
In-Reply-To: <21122.978601587@sss.pgh.pa.us>
References: <Pine.GSO.4.31.0101040151430.3519-100000@sysadmin> <3A543766.B66B482C@debis.com> <21122.978601587@sss.pgh.pa.us>
* 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