pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Joseph Shraibman <jks@selectacast.net>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: aliases break my query
Date: Thu, 25 May 2000 23:11:44 -0400
Message-ID: <392DEB70.86A115E4@selectacast.net> (raw )
These two queries are exactly alike. The first one uses aliases except
for the order by. The second uses aliases also for the order by. The
third uses whole names. The third has the behavior I want.
Someone please tell me what I am doing wrong. I don't want to have to
use whole names for my query.
The data for the tables are at the end.
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;
a|b|c|?column?
-+-+-+--------
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 1
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 1
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 1
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 1
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 1
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 1
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 1
3|4|5| 0
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 1
4|5|4| 0
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 1
1|2| | 0
2|3|4| 0
3|4|5| 0
4|5|4| 0
(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;
a|b|c|?column?
-+-+-+--------
1|2| | 0
1|2| | 0
1|2| | 0
1|2| | 0
1|2| | 0
2|3|4| 1
2|3|4| 1
2|3|4| 0
2|3|4| 0
2|3|4| 0
3|4|5| 0
3|4|5| 0
3|4|5| 1
3|4|5| 0
3|4|5| 0
4|5|4| 0
4|5|4| 0
4|5|4| 0
4|5|4| 1
4|5|4| 0
(20 rows)
playpen=> select tablea.a,tablea.b,tablea.c, (select count (tableb.zz)
where tableb.yy = tablea.a) order by tablea.a;
a|b|c|?column?
-+-+-+--------
1|2| | 0
2|3|4| 2
3|4|5| 1
4|5|4| 1
(4 rows)
playpen=>
playpen=> select * from tablea;
a|b|c
-+-+-
1|2|
2|3|4
3|4|5
4|5|4
(4 rows)
playpen=> select * from tableb;
yy|zz
--+--
2| 4
2| 5
3| 9
4|14
5|15
(5 rows)
view thread (15+ messages) latest in thread
Message-ID: <392DEB70.86A115E4@selectacast.net>
Permalink: ../392DEB70.86A115E4@selectacast.net/
Also on: postgresql.org/message-id/392DEB70.86A115E4@selectacast.net
copy link · copy postgr.es
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
Subject: Re: aliases break my query
In-Reply-To: <392DEB70.86A115E4@selectacast.net>
References: <392DEB70.86A115E4@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