X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BA87556517 for ; Wed, 9 Mar 2005 14:19:47 +0000 (GMT) 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 26089-09 for ; Wed, 9 Mar 2005 14:19:46 +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 8C6B15650C for ; Wed, 9 Mar 2005 14:19:46 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) id 1D922N-000KNi-BS; Wed, 09 Mar 2005 14:19:48 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 52BD916524; Wed, 9 Mar 2005 14:19:46 +0000 (GMT) Message-ID: <422F0601.70103@archonet.com> Date: Wed, 09 Mar 2005 14:19:45 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: lucas@presserv.org Cc: pgsql-sql@postgresql.org Subject: Re: Table like a field References: <20050309104616.8cjneru7plccgss4@www.presserv.org> In-Reply-To: <20050309104616.8cjneru7plccgss4@www.presserv.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.063 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200503/152 X-Sequence-Number: 20631 lucas@presserv.org wrote: > Hello. > Is there any way to build a table that contain the coluns name for the other > table fields? like this: > > create table people(id serial primary key, name varchar(50) ); > create table people_fields ( field_name varchar(30) ); > insert into people_fields values ('occupation'); > insert into people_fields values ('address'); > > then I create any function or view to get: > SELECT * FROM people; //may return > > id - name - | ocuppation - address | You'll want to search the mailing-list archives for "crosstab", and also look in the contrib/ section of the source distribution. -- Richard Huxton Archonet Ltd