Re: Fake table name? - Mailing list pgsql-general

From tolik@aaanet.ru (Anatoly K. Lasareff)
Subject Re: Fake table name?
Date
Msg-id 86wvfhi0pe.fsf@tolikus.hq.aaanet.ru
Whole thread Raw
In response to Fake table name?  ("Roderick A. Anderson" <raanders@altoplanos.net>)
List 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 by date:

Previous
From: "Horst Herb"
Date:
Subject: Re: Question !
Next
From: tolik@aaanet.ru (Anatoly K. Lasareff)
Date:
Subject: Re: how to use plpgsql ?