pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedadd to table which name is in table
2+ messages / 2 participants
[nested] [flat]
* add to table which name is in table
@ 2004-07-17 07:41 teknet@poczta.onet.pl
0 siblings, 1 reply; 2+ messages in thread
From: teknet@poczta.onet.pl @ 2004-07-17 07:41 UTC (permalink / raw)
To: pgsql-admin
Hello
i have table:
create table table_names (
id SERIAL,
name VARCHAR(75) NOT NULL
);
and for each name in table_names i have table (which name is name field from
table_names).
So in table_names i have records:
1 table1
2 table2
3 table3
So i have three other tables named: table1 table2 table3.
And i want to operate on that tables by reading their names from
table_names. I tried:
select * from (select name from table_names where id=1) as something;
but i received only:
table_names
--------------
table1
(1 row)
And i wanted to receive everything from table1.
How can i do it ?
Thanx
Michal
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: add to table which name is in table
@ 2004-07-17 08:39 Oliver Elphick <olly@lfix.co.uk>
parent: teknet@poczta.onet.pl
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Elphick @ 2004-07-17 08:39 UTC (permalink / raw)
To: teknet@poczta.onet.pl; +Cc: pgsql-admin
On Sat, 2004-07-17 at 08:41, teknet@poczta.onet.pl wrote:
> Hello
>
> i have table:
>
> create table table_names (
> id SERIAL,
> name VARCHAR(75) NOT NULL
> );
>
>
>
> and for each name in table_names i have table (which name is name field from
> table_names).
>
> So in table_names i have records:
>
> 1 table1
>
> 2 table2
>
> 3 table3
>
>
>
> So i have three other tables named: table1 table2 table3.
>
> And i want to operate on that tables by reading their names from
> table_names. I tried:
>
> select * from (select name from table_names where id=1) as something;
>
> but i received only:
>
> table_names
> --------------
> table1
> (1 row)
>
> And i wanted to receive everything from table1.
>
> How can i do it ?
SQL can't do that. You would need to do it by EXECUTE statements in a
PL/pgSQL function.
--
Oliver Elphick olly@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"But my God shall supply all your need according to his
riches in glory by Christ Jesus." Philippians 4:19
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-07-17 08:39 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-17 07:41 add to table which name is in table teknet@poczta.onet.pl
2004-07-17 08:39 ` Oliver Elphick <olly@lfix.co.uk>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox