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| 12| 2| 13| 3| 24| 1| 25| 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
--53
(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
--5533
(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