Re: select from table and add rows.

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: select from table and add rows.
Date: 2007-07-06 16:53:33
Message-ID: 20070706165333.GU20115@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)crankycanuck(dot)ca
The plural of anecdote is not data.
--Roger Brinner

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jon Sime 2007-07-06 17:16:42 Re: select from table and add rows.
Previous Message Gary Stainburn 2007-07-06 16:35:39 Re: select from table and add rows.