| From: | "Merlin Moncure" <mmoncure(at)gmail(dot)com> |
|---|---|
| To: | Andrus <kobruleht2(at)hot(dot)ee> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: How to disable duplicate columns |
| Date: | 2007-04-09 19:26:00 |
| Message-ID: | b42b73150704091226t1351ad51u85fb5b021c607a54@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 4/8/07, Andrus <kobruleht2(at)hot(dot)ee> wrote:
> 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?
use can use a natural join:
select * from t1 natural join t2;
this will essentially look for columns that are in both tables, and do
an implicit 'using' on those columns.
be warned, this can lead to surprising behavior -- it only works if
you *want* identically named fields to be part of the join condition,
otherwise the results are undefined.
merlin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2007-04-09 20:20:26 | Re: backend reset of database |
| Previous Message | Matthew T. O'Connor | 2007-04-09 19:24:58 | Re: 8.2.3 AutoVacuum not running |