From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
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-26 23:46:07 |
Message-ID: | 20020926234607.GA16768@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Sep 26, 2002 at 04:04:14PM -0700, 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;
The answer is no. You may be able to fudge it by creating a plpgsql function
that builds the query on the fly but it will probably suck performance-wise.
Sounds like your database structure is not properly normalised.
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Chapman | 2002-09-27 00:39:58 | Re: SQL subquery to supply table name? |
Previous Message | elein | 2002-09-26 23:44:45 | Sizes of sequences and serials |