Re: Ambiguous error message - Mailing list pgsql-sql

From Tom Lane
Subject Re: Ambiguous error message
Date
Msg-id 17379.1073090868@sss.pgh.pa.us
Whole thread Raw
In response to Ambiguous error message  (Samuel Tardieu <sam@rfc1149.net>)
List pgsql-sql
Samuel Tardieu <sam@rfc1149.net> writes:
> In PostgreSQL 7.4, the following select:
> select texten, total
> from (select protocolid, count(*) as total) from ips where catid=1
>       group by protocolid order by protocolid) as c
>   inner join protocols using (protocolid);

> gives the error message:

> ERROR:  subquery in FROM must have an alias
> HINT:  For example, FROM (SELECT ...) [AS] foo.

> Why isn't the "as c" considered as an alias?

It's complaining about this part:

from (select protocolid, count(*) as total) from ips where    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It hasn't gotten as far as noticing your mismatched parentheses and
two top-level FROM keywords yet ;-).

It would probably be helpful if this message included a cursor location...
        regards, tom lane


pgsql-sql by date:

Previous
From: Michael Glaesemann
Date:
Subject: Re: Ambiguous error message
Next
From: Samuel Tardieu
Date:
Subject: Re: Ambiguous error message