Re: Ambiguous error message

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Samuel Tardieu <sam(at)rfc1149(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Ambiguous error message
Date: 2004-01-03 00:47:48
Message-ID: 17379.1073090868@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Samuel Tardieu <sam(at)rfc1149(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Samuel Tardieu 2004-01-03 00:55:12 Re: Ambiguous error message
Previous Message Michael Glaesemann 2004-01-03 00:46:17 Re: Ambiguous error message