Reece Hart wrote:
> On Thu, 2006-12-28 at 19:09 +0700, Akbar wrote:
> Note the 'all' after union... I suspect you'll want that or should at
> least consider it.
Not using it will give the exact same results in a slower way; 'blue'
and 'red' are different, after all. You'll be hard pressed to find
On Thu, 2006-12-28 at 19:09 +0700, Akbar wrote:
> select blue.name from blue union select red.name from red
> give me this:
> name
> 'blabla'
> 'bubu'
> 'haha'
> 'kkk'
>
> I want this:
> nametable_name
> 'blabla' blue
> 'bubu'blue
> 'haha'red
> 'kkk' red
>
> Could I?
select
rg
Subject: [GENERAL] select union with table name
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
> I want this:
> nametable_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
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Akbar
>Sent: donderdag 28 december 2006 13:10
>To: pgsql-general@postgresql.org
>Subject: [GENERAL] select union with table name
>
>Hi, I have two tables.
>create table blue (
> id serial primary
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'
'hah
Randall Skelton <[EMAIL PROTECTED]> writes:
> As you suggested, while this is much shorter in length, it is
> considerably longer in execution.
>> SELECT t1.timestamp FROM (
>> SELECT timestamp FROM cal_quat_1 UNION
>> SELECT timestamp FROM cal_quat_2 UNION
>> SELECT timestamp FROM cal_quat_3 UNI