pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joseph Shraibman <jks@selectacast.net>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: aliases break my query
Date: Fri, 26 May 2000 13:47:03 -0400
Message-ID: <392EB897.203DE4AE@selectacast.net> (raw)
References: <Pine.GSO.4.02A.10005261453420.12244-100000@Falk.DoCS.UU.SE>

Peter Eisentraut wrote:
> 
> > > playpen=> select ta.a,ta.b,ta.c, (select count (tb.zz) where tb.yy =
> > > ta.a) from tablea ta, tableb tb order by tablea.a;
> > [ produces 80 rows ]
> 
> > > playpen=> select ta.a,ta.b,ta.c, (select count (tb.zz) where tb.yy =
> > > ta.a) from tablea ta, tableb tb order by ta.a;
> > [ produces 20 rows ]
> 
> > > playpen=> select tablea.a,tablea.b,tablea.c, (select count (tableb.zz)
> > > where tableb.yy = tablea.a) order by tablea.a;
> > [ produces 4 rows ]
> 
> Once again, I think that we *really* need to discuss whether implicit
> range table entries in SELECT are a good idea.

What is an "implicit range table entry"?

 We invariably get a
> question like this every week and invariably the answer is "if you give a
> table an alias you *must* refer to it by that alias".

Hey, I *did* do that in the second query, and that still produced extra
results. I tried putting the aliases in the inner select too but that
didn't help. In fact the inner select always is 4 in that case. Unless I
only alias tableb in the inner query, and let it get the definition of
tablea from the outer query.


 (I'm sure Tom has
> this reply automated by now.) I claim the only thing that buys is
> confusion for very little convenience at the other end.
> 
> Stop the madness! :)
> 
> --
> Peter Eisentraut                  Sernanders väg 10:115
> peter_e@gmx.net                   75262 Uppsala
> http://yi.org/peter-e/            Sweden



view thread (15+ messages)  latest in thread

Message-ID: <392EB897.203DE4AE@selectacast.net>
Permalink:  ../392EB897.203DE4AE@selectacast.net/
Also on:    postgresql.org/message-id/392EB897.203DE4AE@selectacast.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: jks@selectacast.net, peter_e@gmx.net, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org
  Subject: Re: aliases break my query
  In-Reply-To: <392EB897.203DE4AE@selectacast.net>
  References: <Pine.GSO.4.02A.10005261453420.12244-100000@Falk.DoCS.UU.SE> <392EB897.203DE4AE@selectacast.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