Re: [GENERAL] select union with table name

2007-01-02 Thread Alban Hertroys
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

Re: [GENERAL] select union with table name

2006-12-28 Thread Reece Hart
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

Re: [GENERAL] select union with table name

2006-12-28 Thread Richard Broersma Jr
> 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

Re: [GENERAL] select union with table name

2006-12-28 Thread Joris Dobbelsteen
Try: select blue.name, 'blue' from blue union select red.name, 'red' from red; Not tested, but that should work. One thing to remember: If blabla is in both blue and red, it will appear twice, instead of only once as in your example. - Joris >-Original Message- >From: [EMAIL PROTECTED]

Re: [GENERAL] Select Union

2004-04-01 Thread Tom Lane
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