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 200209261745.20376.scott_list@mischko.com
Whole thread Raw
In response to SQL subquery to supply table name?  (Scott Chapman <scott_list@mischko.com>)
Responses Re: SQL subquery to supply table name?  (Martijn van Oosterhout <kleptog@svana.org>)
Re: SQL subquery to supply table name?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List 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


pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: SQL subquery to supply table name?
Next
From: Martijn van Oosterhout
Date:
Subject: Re: SQL subquery to supply table name?