Re: select union with table name

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Akbar <akbarhome(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: select union with table name
Date: 2006-12-28 13:00:52
Message-ID: 473133.66672.qm@web31810.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I want this:
> name table_name
> 'blabla' blue
> 'bubu' blue
> 'haha' red
> 'kkk' red
>
> Could I?

Here is an example from the table inheritance chapter:

SELECT p.relname, c.name, c.altitude
FROM cities c, pg_class p
WHERE c.altitude > 500 and c.tableoid = p.oid;

which returns:

relname | name | altitude
----------+-----------+----------
cities | Las Vegas | 2174
cities | Mariposa | 1953
capitals | Madison | 845

http://www.postgresql.org/docs/8.2/interactive/ddl-inherit.html

it should do what you want.

Regards,

Richard Broersma Jr.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2006-12-28 13:23:20 Re: Re: [GENERAL] ??: [GENERA
Previous Message Joris Dobbelsteen 2006-12-28 12:41:44 Re: select union with table name