From: | Joseph Shraibman <jks(at)selectacast(dot)net> |
---|---|
To: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | aliases break my query |
Date: | 2000-05-26 03:11:44 |
Message-ID: | 392DEB70.86A115E4@selectacast.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-sql |
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)
From | Date | Subject | |
---|---|---|---|
Next Message | Hiroshi Inoue | 2000-05-26 03:16:06 | RE: Orphaned locks in 7.0? |
Previous Message | Bruce Momjian | 2000-05-26 02:15:41 | Re: Re: gram.y PROBLEM with UNDER |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-05-26 04:35:14 | Re: aliases break my query |
Previous Message | Tom Lane | 2000-05-26 00:03:18 | Re: Use of index in 7.0 vs 6.5 |