Re: SQL subquery to supply table name? - Mailing list pgsql-general

From Scott Chapman
Subject Re: SQL subquery to supply table name?
Date
Msg-id 200209261940.37792.scott_list@mischko.com
Whole thread Raw
In response to Re: SQL subquery to supply table name?  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: SQL subquery to supply table name?
List pgsql-general
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?

Scott

On Thursday 26 September 2002 06:01 pm, Martijn van Oosterhout wrote:
> I think the basic response is "don't do that". SQL doesn't support queries
> where the tables are not predetermined. The query planner would have a
> terrible time since it would not be able to estimate costs prior to
> execution.
>
> Since all your "subtables" are likely to have the same structure, why not
> store them all in one table. Any particular reason?


pgsql-general by date:

Previous
From: Scott Chapman
Date:
Subject: Re: SQL subquery to supply table name?
Next
From: Tom Lane
Date:
Subject: Re: Unixtime (epoch) into timestamp?