Re: select from table and add rows. - Mailing list pgsql-sql

From Andrew Sullivan
Subject Re: select from table and add rows.
Date
Msg-id 20070706165333.GU20115@phlogiston.dyndns.org
Whole thread Raw
In response to Re: select from table and add rows.  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Gary Stainburn
Date:
Subject: Re: select from table and add rows.
Next
From: Jon Sime
Date:
Subject: Re: select from table and add rows.