implied FROM

From: "Matt Mello" <alien(at)spaceship(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: implied FROM
Date: 2003-05-02 02:06:37
Message-ID: 34943.24.243.219.116.1051841197.squirrel@earth.spaceship.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message A.Bhuvaneswaran 2003-05-02 04:45:00 Re: differences between oracle,pgsql,sybase
Previous Message Josh Berkus 2003-05-01 17:04:20 Re: date use in for loop