From: pgsql-admin <pgsql-admin@fc.emc.com.ph>
To: Chris@pcguru.com
Cc: pgsql-admin@postgresql.org
Subject: Re: Populating a Table
Date: Mon, 30 Oct 2000 10:42:50 +0800
Message-ID: <fc.000f56720078965b000f56720078965b.789685@fc.emc.com.ph> (raw)
try
INSERT INTO table2
SELECT DISTINCT ON key key, name, field1, field2
FROM table1;
sherwin
Chris@pcguru.com writes:
>Hello,
>
>I'm sure I'll be flagged as a moron for asking this question, so be it.
>
>I have some tables of info with no primary keys. As a result the field I
>want to key on is repeated. My plan is to do a DISTINCT select from the
>un-keyed table into another table that does have constraints.
>
>Here is what I thought would work:
>
>INSERT INTO table2
> SELECT DISTINCT(key), name, field1, field2
> FROM table1;
>
>When I issue this statement it tells me that you cannot put in duplicate
>values into my key field. Why does it do that? If I issue the following
>statement I get exactly what I want:
>
>SELECT DISTINCT(phone) from table1;
>
>Am I using the DISTINCT function incorrectly? Is it taking all of the
>field and using them to create a distinct row?
>
>Any help would be appreciated.
>
>Chris.
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: pgsql-admin@fc.emc.com.ph, Chris@pcguru.com
Subject: Re: Populating a Table
In-Reply-To: <fc.000f56720078965b000f56720078965b.789685@fc.emc.com.ph>
References: <fc.000f56720078965b000f56720078965b.789685@fc.emc.com.ph>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox