Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
[PostgreSQL 6.6.0 on i386-unknown-freebsd3.2, compiled by gcc 2.7.2.1]

(a side note - wouldn't it be helpful to have a little more info about the
build, namely its time stamp and/or the CVS time stamp)

test=> \d ord
Table = ord
+----------------------------------+----------------------------------+-----
--+
Field | Type |
Length|
+----------------------------------+----------------------------------+-----
--+
id | int4 | 4 |
pos | int4 | 4 |
tp | int4 |
4 |
+----------------------------------+----------------------------------+-----
--+

test=> select * from ord;
id|pos|tp
--+---+--
1| 1| 1
2| 2| 1
3| 3| 2
4| 1| 2
5| 3| 1
(5 rows)

This query is fine:

test=> select o1.id from ord as o1, ord as o2 where o1.pos>2 and o2.pos<2
test-> and o1.tp=o2.tp;
id
--
5
3
(2 rows)

And this one is invalid:

test=> select o1.id from ord as o1, ord as o2 where o1.pos>2 and o2.pos<2
test-> and o1.tp=o2.tp and ord.id>3;
id
--
5
5
3
3
(4 rows)

This query should probably fail instead of returning an invalid result. MS
SQL 6.5 does just that:

Msg 107, Level 16, State 3
The column prefix 'ord' does not match with a table name or alias name used
in the query.

Gene Sokolov

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedNov 19, '99 at 3:17p
activeNov 19, '99 at 8:13p
posts3
users3
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2021 Grokbase