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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: change the order of FROM selection to make query work


  • From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
  • To: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
  • Cc: Thomas Peter <thomas(at)braindumped(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org>
  • Subject: Re: change the order of FROM selection to make query work
  • Date: Wed, 27 Sep 2006 17:11:58 -0400
  • Message-id: <6818.1159391518@sss.pgh.pa.us> <text/plain>

Scott Marlowe <smarlowe(at)g2switchworks(dot)com> writes:
> On Tue, 2006-09-26 at 09:19, Tom Lane wrote:
>> I was aware that MySQL parses this sort of structure wrongly, but it's
>> disappointing to hear that sqlite does too :-(

> And I think MySQL fixed this abberant behaviour in the newest beta.

Actually they seem to have fixed it awhile ago --- I get this in 5.0.22:

mysql> create table t1(f1 int);
Query OK, 0 rows affected (0.02 sec)

mysql> create table t2(f2 int);
Query OK, 0 rows affected (0.01 sec)

mysql> select * from t1 c, t2 a join t1 b on (a.f2 = b.f1);
Empty set (0.00 sec)

mysql> select * from t1 c, t2 a join t1 b on (a.f2 = c.f1);
ERROR 1054 (42S22): Unknown column 'c.f1' in 'on clause'

mysql> select * from t1 c cross join t2 a join t1 b on (a.f2 = c.f1);
Empty set (0.01 sec)

which appears to conform to the letter of the standard.

FYI, PG 8.2 will produce a possibly more useful error message:

regression=# select * from t1 c, t2 a join t1 b on (a.f2 = c.f1);
ERROR:  invalid reference to FROM-clause entry for table "c"
LINE 1: select * from t1 c, t2 a join t1 b on (a.f2 = c.f1);
                                                      ^
HINT:  There is an entry for table "c", but it cannot be referenced from this part of the query.
regression=#


			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group