Re: SQL subquery to supply table name?

From: Scott Chapman <scott(at)mischko(dot)com>(by way of Scott Chapman <scott_list(at)mischko(dot)com>)
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL subquery to supply table name?
Date: 2002-09-27 00:39:58
Message-ID: 200209261739.58307.scott_list@mischko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

Scott

On Thursday 26 September 2002 04:04 pm, Scott Chapman wrote:
> I have a situation where a table contains table names. I need to know if I
> can make a Postgresql query that will have a subquery which supplies the
> table name I want to deal with. Can this be done?
>
> Something like this:
> select column from (select table_name from table2 where key=value) where
> key=value;
>
> Scott
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

Browse pgsql-general by date

  From Date Subject
Next Message Scott Chapman 2002-09-27 00:45:20 Re: SQL subquery to supply table name?
Previous Message Martijn van Oosterhout 2002-09-26 23:46:07 Re: SQL subquery to supply table name?