| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| 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-03 05:01:46 |
| Message-ID: | 16839.970549306@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
"Roderick A. Anderson" <raanders(at)altoplanos(dot)net> writes:
> select tbl_key, equipname from equipment
> UNION
> select 'All', 'All Equipment' from ???
Postgres has a cleaner answer than a fake table; just omit the
FROM clause:
regression=# create table equipment(tbl_key text, equipname text);
CREATE
regression=# select tbl_key, equipname from equipment
regression-# UNION
regression-# select 'All', 'All Equipment';
tbl_key | equipname
---------+---------------
All | All Equipment
(1 row)
In some cases you might need to explicitly assign a datatype to the
literals, eg 'All'::text, but in the above example it should work
without that.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Mart Käsper | 2000-10-03 09:03:24 | Q : aborting requests ? |
| Previous Message | Tom Lane | 2000-10-03 04:56:56 | Re: Problem with nested query |