Re: SQL subquery to supply table name?

Поиск
Список
Период
Сортировка
От Scott Chapman
Тема Re: SQL subquery to supply table name?
Дата
Msg-id 200209261642.07602.scott@mischko.com
обсуждение исходный текст
Ответ на SQL subquery to supply table name?  (Scott Chapman <scott_list@mischko.com>)
Список 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 по дате отправления:

Предыдущее
От: Rod Taylor
Дата:
Сообщение: Re: [HACKERS] Performance while loading data and indexing
Следующее
От: elein
Дата:
Сообщение: Sizes of sequences and serials