Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B605E9FB8DA for ; Fri, 6 Jul 2007 10:55:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 13234-10 for ; Fri, 6 Jul 2007 10:55:44 -0300 (ADT) X-Greylist: delayed 00:27:20.669584 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 05EB19FC0AB for ; Fri, 6 Jul 2007 10:55:44 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mail.ringways.co.uk (unknown [80.193.83.130]) by svr4.postgresql.org (Postfix) with ESMTP id 193455AF8A5 for ; Fri, 6 Jul 2007 13:28:22 +0000 (GMT) Received: from eddie.ringways.co.uk ([10.1.1.115]) by mail.ringways.co.uk with esmtp (Exim 4.62) (envelope-from ) id 1I6nle-00063F-Bp for pgsql-sql@postgresql.org; Fri, 06 Jul 2007 14:22:38 +0100 From: Gary Stainburn Organization: Ringways Garages Ltd To: pgsql-sql@postgresql.org Subject: select from table and add rows. Date: Fri, 6 Jul 2007 14:25:08 +0100 User-Agent: KMail/1.9.5 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200707061425.09074.gary.stainburn@ringways.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/35 X-Sequence-Number: 28770 Hi folks. In PHP I often do things such as: $wpartners=array('all'=>'All','sel'=>'Current','mine'=>'Mine'); foreach( loadhash("select p_id as key, p_name as value from partners order by p_name" ) as $key=>$dets) { $wpartners[$key]=$dets; } This sets up an array with some pseudo values and then populates it with *proper* values from a table. How's the best way to do this all within SQL. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000