select union with table name

From: Akbar <akbarhome(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: select union with table name
Date: 2006-12-28 12:09:33
Message-ID: 5e8843f90612280409t7cd2695eg65a1ddf6d7b552fd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, I have two tables.
create table blue (
id serial primary key,
name text not null,
kill text not null
);

create table red (
id serial primary key,
name text not null,
kiss text not null
);

select blue.name from blue union select red.name from red; give me this:
name
'blabla'
'bubu'
'haha'
'kkk'

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

Could I?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joris Dobbelsteen 2006-12-28 12:41:44 Re: select union with table name
Previous Message Akbar 2006-12-28 12:01:08 unique constraint on more than one tables