Re: Fake table name?

From: tolik(at)aaanet(dot)ru (Anatoly K(dot) Lasareff)
To: "Roderick A(dot) Anderson" <raanders(at)altoplanos(dot)net>
Cc: "PostgreSQL::General List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Fake table name?
Date: 2000-10-10 08:01:49
Message-ID: 86wvfhi0pe.fsf@tolikus.hq.aaanet.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "RAA" == Roderick A Anderson <raanders(at)altoplanos(dot)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(at)aaanet(dot)ru

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anatoly K. Lasareff 2000-10-10 08:06:32 Re: how to use plpgsql ?
Previous Message He Weiping (Laser Henry) 2000-10-10 07:06:22 Is there any caveats on toasted fields?