Skip site navigation (1) Skip section navigation (2)

Re: aliases break my query

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: aliases break my query
Date: 2000-05-26 17:47:03
Message-ID: 392EB897.203DE4AE@selectacast.net (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-sql
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(at)gmx(dot)net                   75262 Uppsala
> http://yi.org/peter-e/            Sweden

In response to

pgsql-hackers by date

Next:From: Joseph ShraibmanDate: 2000-05-26 18:13:35
Subject: Re: aliases break my query
Previous:From: Tom LaneDate: 2000-05-26 16:26:06
Subject: Re: aliases break my query

pgsql-sql by date

Next:From: Joseph ShraibmanDate: 2000-05-26 18:13:35
Subject: Re: aliases break my query
Previous:From: Richard HuxtonDate: 2000-05-26 17:41:33
Subject: Re: POSTGRESQL and PERL?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group