From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | scott_list(at)mischko(dot)com |
Cc: | pgsql-general(at)postgresql(dot)org, Martijn van Oosterhout <kleptog(at)svana(dot)org> |
Subject: | Re: SQL subquery to supply table name? |
Date: | 2002-09-27 04:16:28 |
Message-ID: | 3D93DB9C.8090102@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Scott Chapman wrote:
> I was lead to believe that Postgresql would handle this from reading the docs.
> This error message from psql made me think it would also:
>
> select txtcompanyname from (select table_quest from reviews where
> review_num=28) where review_num=28;
>
> ERROR: sub-SELECT in FROM must have an alias
> For example, FROM (SELECT ...) [AS] foo
>
> What is the "sub-SELECT in FROM" supposed to be used for if not this usage?
>
Read the error message again -- you just need an alias for the sub-select, e.g.:
select
t.table_quest
from
(select table_quest from reviews where review_num=28) AS t;
^^^^^
^^^^^
HTH,
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2002-09-27 04:34:11 | Re: get date in binary number format |
Previous Message | Tom Lane | 2002-09-27 04:14:42 | Re: get date in binary number format |