Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 6F37A9FB34E for ; Fri, 6 Jul 2007 13:54:00 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 15799-06 for ; Fri, 6 Jul 2007 13:53:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id A41419FB37A for ; Fri, 6 Jul 2007 13:53:43 -0300 (ADT) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1I6r3q-00012o-N7 for pgsql-sql@postgresql.org; Fri, 06 Jul 2007 12:53:38 -0400 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 45EE23F9E; Fri, 6 Jul 2007 12:53:33 -0400 (EDT) Date: Fri, 6 Jul 2007 12:53:33 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: select from table and add rows. Message-ID: <20070706165333.GU20115@phlogiston.dyndns.org> References: <200707061425.09074.gary.stainburn@ringways.co.uk> <20070706150257.GS20115@phlogiston.dyndns.org> <200707061735.39592.gary.stainburn@ringways.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200707061735.39592.gary.stainburn@ringways.co.uk> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/40 X-Sequence-Number: 28775 On Fri, Jul 06, 2007 at 05:35:39PM +0100, Gary Stainburn wrote: > > I want to be able to do away with the first line of the code, and create a > select statement that would generate the three rows first, followed by the > rows from the table I'm using. I want to be able to do the same job without > having to pre-load the array. Oh, I see. > In other words, what's the best way to inject pre-defined rows into a select > statement. Probably a UNION statement. Something like SELECT 'something'::text as a, 'else'::text as b, 'and other'::text as c UNION SELECT a::text, b::text, c::text FROM sometable WHERE [criteria] The casts might not be needed, of course. A -- Andrew Sullivan | ajs@crankycanuck.ca The plural of anecdote is not data. --Roger Brinner