Re: SQL subquery to supply table name?

From: Scott Chapman <scott_list(at)mischko(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Subject: Re: SQL subquery to supply table name?
Date: 2002-09-27 02:40:37
Message-ID: 200209261940.37792.scott_list@mischko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-09-27 02:44:33 Re: Unixtime (epoch) into timestamp?
Previous Message Scott Chapman 2002-09-27 02:33:08 Re: SQL subquery to supply table name?