Re: Order of items in FROM causes error?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rosser Schwarz <rosser(dot)schwarz(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Order of items in FROM causes error?
Date: 2005-04-01 16:35:18
Message-ID: 7051.1112373318@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Rosser Schwarz <rosser(dot)schwarz(at)gmail(dot)com> writes:
> A colleague has the following query, which errors with: relation "dl"
> does not exist. (See the second item in the FROM clause.) If that
> item is moved to immediately precede the first JOIN item however, the
> query works as expected.

> select u.usersfirstname || ' ' || u.userslastname as userssupervisorsname
> , l.locationsname || ' >> ' || lv.listvaluesname as locationdepartment
> , lvcat.listvaluesname as usersemploymentcategory
> , lvclass.listvaluesname as usersemploymentclass
> , lvacdcat.listcategoriesname as usersacdcategory
> from intranet.tbl_users u
> , intranet.tbl_departmentslocations dl
> , intranet.tbl_listvalues lvcat
> , intranet.tbl_listvalues lvclass
> , intranet.tbl_listcategories lvacdcat
> join intranet.tbl_listvalues lv on dl.listvaluesid = lv.listvaluesid
> join intranet.tbl_locations l on dl.locationsid = l.locationsid
> where u.usersid = 199
> and dl.listvaluesid = 13
> and lvcat.listvaluesid = 23
> and lvclass.listvaluesid = 27
> and lvacdcat.listcategoriesid = 6

> This strikes me as a bug.

No, it isn't, because JOIN binds more tightly than comma. (People
coming from MySQL tend to misunderstand this, because MySQL gets it
wrong...)

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2005-04-01 16:37:59 Re: Order of items in FROM causes error?
Previous Message Rosser Schwarz 2005-04-01 16:24:12 Order of items in FROM causes error?