Re: select from table and add rows.

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: select from table and add rows.
Дата
Msg-id 20070706165333.GU20115@phlogiston.dyndns.org
обсуждение исходный текст
Ответ на Re: select from table and add rows.  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: Gary Stainburn
Дата:
Сообщение: Re: select from table and add rows.
Следующее
От: Jon Sime
Дата:
Сообщение: Re: select from table and add rows.