From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-sql@postgresql.org
Subject: Re: select from table and add rows.
Date: Fri, 6 Jul 2007 12:53:33 -0400
Message-ID: <20070706165333.GU20115@phlogiston.dyndns.org> (raw)
In-Reply-To: <200707061735.39592.gary.stainburn@ringways.co.uk>
References: <200707061425.09074.gary.stainburn@ringways.co.uk>
<20070706150257.GS20115@phlogiston.dyndns.org>
<200707061735.39592.gary.stainburn@ringways.co.uk>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ajs@crankycanuck.ca
Subject: Re: select from table and add rows.
In-Reply-To: <20070706165333.GU20115@phlogiston.dyndns.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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