Re: Fake table name?

Поиск
Список
Период
Сортировка
От tolik@aaanet.ru (Anatoly K. Lasareff)
Тема Re: Fake table name?
Дата
Msg-id 86wvfhi0pe.fsf@tolikus.hq.aaanet.ru
обсуждение исходный текст
Ответ на Fake table name?  ("Roderick A. Anderson" <raanders@altoplanos.net>)
Список pgsql-general
>>>>> "RAA" == Roderick A Anderson <raanders@altoplanos.net> writes:

 RAA> I know I've seen this but can't even begin to guess where that was so I'll
 RAA> ask.  I need to add a fake entry to a UNION.  A row that doesn't exist in
 RAA> the table and shouldn't.  It's for a CGI script where I want the user have
 RAA> the all/none/whatever option.

 RAA> select tbl_key, equipname from equipment
 RAA> UNION
 RAA> select 'All', 'All Equipment' from ???

 RAA> Heck I can't even remember what is was called in Oracle.

I guess answer is (assume tbl_key is varchar(20), and equipname is text type):

select tbl_key, equipname from equipment
 UNION
select 'All'::varchar as tbl_key , 'All Equipment'::text as equipname;

You don't need 'from' clause in PostgreSQL in this case.

--
Anatoly K. Lasareff              Email:       tolik@aaanet.ru

В списке pgsql-general по дате отправления:

Предыдущее
От: "Horst Herb"
Дата:
Сообщение: Re: Question !
Следующее
От: tolik@aaanet.ru (Anatoly K. Lasareff)
Дата:
Сообщение: Re: how to use plpgsql ?