X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E4B67D1B1CE for ; Sat, 17 Jul 2004 05:39:55 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57991-03 for ; Sat, 17 Jul 2004 08:39:51 +0000 (GMT) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by svr1.postgresql.org (Postfix) with ESMTP id 25140D1B392 for ; Sat, 17 Jul 2004 05:39:41 -0300 (ADT) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 1BlkjU-0004Fs-0X; Sat, 17 Jul 2004 09:39:48 +0100 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.34) id 1BlkjN-0005nc-DT; Sat, 17 Jul 2004 09:39:41 +0100 Subject: Re: add to table which name is in table From: Oliver Elphick Reply-To: olly@lfix.co.uk To: teknet@poczta.onet.pl Cc: pgsql-admin@postgresql.org In-Reply-To: <20040717074205Z135895-30879+518592@kps2.test.onet.pl> References: <20040717074205Z135895-30879+518592@kps2.test.onet.pl> Content-Type: text/plain Organization: LFIX Limited Message-Id: <1090053581.25749.69.camel@linda> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Sat, 17 Jul 2004 09:39:41 +0100 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/196 X-Sequence-Number: 14264 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