How to disable duplicate columns

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: How to disable duplicate columns
Date: 2007-04-08 19:03:54
Message-ID: evbevb$19no$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have tables with large number of columns some of which are duplicate.
I need to use

SELECT t1.*, t2.* FROM t1 join t2 using (t)

since I don't know all column names of t1 and t2 tables at design time.

In this case PostgreSQL returns table with duplicate columns.
How to force Postgres to return only first table column when second table
contains column with same name?

Code to reproduce:

create table t1 ( id integer
/*, a lot of other columns */ );
create table t2 ( id integer
/*, a lot of other columns */ );
create table t3 as select t1.*,t2.* from t1 join t2 using (id);

Observed:

Error: Column name is duplicated

Expected:

t3 table should contain single id column

Andrus.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sergei Shelukhin 2007-04-08 21:16:06 join by char(16) or by bytea?
Previous Message marcel.beutner 2007-04-08 16:52:39 Re: newid() in postgres