Re: query with table alias - Mailing list pgsql-general

From Matteo Beccati
Subject Re: query with table alias
Date
Msg-id 41949CD8.5070900@beccati.com
Whole thread Raw
In response to query with table alias  ("Rodríguez Rodríguez, Pere" <prr@hosppal.es>)
List pgsql-general
> prr=# select foo.c1, f.c2 from foo f;  -- >>> Incorrect result <<<
>
> The result of the "select foo.c1, f.c2 from foo f" isn't correct, it do
> a cartesian product of foo table.

foo is aliased to f, so there's no table named foo in the from clause.
By default postgres tries to add the missing table name, so your query
get rewritten as:

select foo.c1, f.c2 from foo f, foo;

You should also receive a:

NOTICE:  adding missing FROM-clause entry for table "foo"


Best regards
--
Matteo Beccati
http://phpadsnew.com
http://phppgads.com


pgsql-general by date:

Previous
From: "Patrick Fiche"
Date:
Subject: Re: query with table alias
Next
From: "Goutam Paruchuri"
Date:
Subject: Re: simple query question: return latest