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

Re: Strange Query Question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: OTR Comm <otrcomm(at)wildapache(dot)net>
Cc: PGSQL Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Strange Query Question
Date: 2000-11-20 20:12:57
Message-ID: 4298.974751177@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
OTR Comm <otrcomm(at)wildapache(dot)net> writes:
> $query = qq|SELECT ap.id, ap.invnumber, vendor.name,   
>               acc_trans.transdate, ap.invoice, acc_trans.amount
>               FROM ap, acc_trans        
>               WHERE $where
>               AND acc_trans.accno = $form->{accno}
>               AND acc_trans.trans_id = ap.id
>               AND ap.vendor = vendor.id|;

> The code executes properly, but I do not see how this query can work
> without a FROM reference to the vendor table.  How does this happen?

Postgres lets you get away with that.  It's not strictly legal per
SQL92, but the equivalent construction worked in the old PostQuel
language, and we've just sort of never wanted to break it.

This has confused a lot of people, so beginning in 7.1 there'll be
a warning notice when you mix explicit-FROM and implied-FROM styles
as above:

NOTICE:  Adding missing FROM-clause entry for table "vendor"

			regards, tom lane

In response to

pgsql-novice by date

Next:From: D. DucciniDate: 2000-11-20 21:20:48
Subject: MODPERL EXAMPLE ?
Previous:From: OTR CommDate: 2000-11-20 19:55:25
Subject: Strange Query Question

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group