Обсуждение: Default column titles in a select...
Hi, maybe it's a novice question, but I stumpled across the following problem and couldn't find a solution: create table c( atext varchar ); create table a( objid smallint, )INHERITS(c); create table b( objid smallint, )INHERITS(c); insert into a values(1,'foobar'); insert into b values(1,'carcddr'); When doing the following select statement: select * from a,b where a.objid=b.objid postgresql returns four columns labeled objid atext objid atext instead of what I expected: a.objid a.atext b.objid b.atext With the current result I'm unable to differentiate between the two 'atext' column. Is there any possibility to get column headers including the table name in the result ? Bye, Axel -- "The virus spreads using a Microsoft vulnerability known as 'MS SQL Server'"
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 >When doing the following select statement: > select * from a,b where a.objid=b.objid >postgresql returns four columns labeled > objid atext objid atext >instead of what I expected: > a.objid a.atext b.objid b.atext You will have to explicitly specify them yourself: SELECT a.objid AS "a.objid", a.atext AS "a.atext", b.objid AS "b.objid", b.atext AS "b.atext" to get the results you want. - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200302191003 -----BEGIN PGP SIGNATURE----- Comment: http://www.turnstep.com/pgp.html iD8DBQE+U5zTvJuQZxSWSsgRAlxWAKDrB+q9NsiXLAsudRQDu+2p7ma94wCeKMC/ box5pl2CIsjsjD979gKZ3/8= =0k+n -----END PGP SIGNATURE-----
On Wed, Feb 19, 2003 at 15:25:41 +0100, Axel Schlueter <axel@pqrs.de> wrote: > > When doing the following select statement: > select * from a,b where a.objid=b.objid > postgresql returns four columns labeled > objid atext objid atext > instead of what I expected: > a.objid a.atext b.objid b.atext Use something like: select a.objid as "a.objib", a.atext as "a.atext", b.objid as "b.objid", b.atext as "b.atext" from a,b where a.objid=b.objid;
> > When doing the following select statement: > select * from a,b where a.objid=b.objid > postgresql returns four columns labeled > objid atext objid atext > instead of what I expected: > a.objid a.atext b.objid b.atext > > With the current result I'm unable to differentiate > between the two 'atext' column. Is there any possibility > to get column headers including the table name in the > result ? > SELECT a.objid AS a_objid, a.atext AS a_atext, b.objid AS b_objid, b.atext AS b_atextFROM a, b WHERE a.objid=b.objid ; Does this help? Probably not really. Regards, Christoph