Re: novice question about NOTICE:...

From: Doug Silver <dsilver(at)quantified(dot)com>
To: Lloyd Vancil <lev(at)apple(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: novice question about NOTICE:...
Date: 2002-04-03 20:55:16
Message-ID: Pine.LNX.4.21.0204031251110.22347-100000@danzig.sd.quantified.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Wed, 3 Apr 2002, Lloyd Vancil wrote:

> Tried to search the novice archives and the engine just never
> returns an answer. This is probably a pretty common question so I
> hope I'll get a quick answer.
>
>
> I have two tables cgidat and tierdat.
> I want to select all occurrences of data in cgidat where
> cgidat.state = testing and cgidat.lang = tierdat.lang and
> tierdat.tier = 0
>
> so I did
>
>
> select oid, lang from cgidat where cgidat.state = 'testing' and
> cgidat.lang = tiredat.lang and tierdat.tier = '0' order by lang;
>
> I get the expected results but I also get
> Adding missing FROM-clause entry for table "tierdat"
>
>
> Huh?
>
> Thanks
> Lloyd
>
>

That was mighty nice of Postgres to fix your query -- I didn't know it
would do that. You're doing a join from two tables, cgidat and tierdat,
so you must include them in your FROM clause:

select oid, lang from cgidat, tierdat where
cgidat.state = 'testing' and
cgidat.lang = tiredat.lang and
tierdat.tier = '0' order by lang;

or using aliases (a must when you start joining several tables):

select c.oid,c.lang from cgidat c, tierdat t where
c.state='testing' and
c.lang = t.lang and
t.tier ='0' order by c.lang

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Doug Silver
Network Manager
Quantified Systems, Inc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Lloyd Vancil 2002-04-03 22:26:09 Re: novice question about NOTICE:...
Previous Message Lloyd Vancil 2002-04-03 20:41:03 Re: finding out about databases and tables