implied FROM - Mailing list pgsql-sql

From Matt Mello
Subject implied FROM
Date
Msg-id 34943.24.243.219.116.1051841197.squirrel@earth.spaceship.com
Whole thread Raw
Responses Re: implied FROM  (Tomasz Myrta <jasiek@klaster.net>)
List pgsql-sql
Hello, all.  New to this list.  If this isn't the right place for this
issue, please let me know.

Here is a condensed version of the situation.  I have two tables (STORE and
APPLIANCE).  They share a field name STOREID, where the field is a primary
key in STORE and a foreign key in APPLIANCE.

1) Here is what I *should* have typed in:
select appliance.storeid from appliance where appliance.applianceid = 32;

2) Here is what I accidentally typed in:
select store.storeid from appliance where appliance.applianceid = 32;

#1 gives me a single int4 column in a single-row resultset.
#2 gives me a single int4 column in a resultset that has a row for every row
in STORE.

I finally figured out my error, but I would have found it much faster if the
problem query had thrown an exception.

So, why doesn't asking for a field from a table that IS NOT in the from
clause throw an exception?  Isn't it violating the SQL language?  Why is PG
implying FROM tables?

Thanks!

--
Matt Mello



pgsql-sql by date:

Previous
From: "Daniel Dunajsky"
Date:
Subject: How to write an query to get this result?
Next
From: "A.Bhuvaneswaran"
Date:
Subject: Re: differences between oracle,pgsql,sybase