Re: SQL subquery to supply table name?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Scott Chapman <scott_list(at)mischko(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL subquery to supply table name?
Date: 2002-09-27 01:02:10
Message-ID: 20020926180014.G32077-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 26 Sep 2002, Scott Chapman wrote:

> Here's the details:
> Table "reviews"
> Column | Type | Modifiers
> ---------------------------------+---------+----------------------------------------
> review_num | integer | default
> nextval('review_number'::text)
> table_quest | text |
>
>
> Table "mpe_quest"
> Column | Type | Modifiers
> ------------------------+---------+-----------
> review_num | integer |
> txtcompanyname | text |
>
>
> select foo.txtcompanyname from (select table_quest from reviews where
> review_num=28) as foo where review_num=28;
> It comes back and says No such attribute or function foo.txtcompanyname.

Yep, foo has a table_quest column. In 7.3 (now in beta) you probably
could make a function that returns a rowset from the table given as
its argument.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Elein Mustain 2002-09-27 01:09:27 Sizes of sequences and serials (fwd)
Previous Message Martijn van Oosterhout 2002-09-27 01:01:44 Re: SQL subquery to supply table name?