Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 5A1BC9FB6AE for ; Sat, 24 Feb 2007 21:18:04 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 57701-02 for ; Sat, 24 Feb 2007 21:18:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from weatherbeeta.com.au (218-214-212-153.people.net.au [218.214.212.153]) by postgresql.org (Postfix) with SMTP id 257489FB68D for ; Sat, 24 Feb 2007 21:17:59 -0400 (AST) Received: (qmail 21047 invoked from network); 25 Feb 2007 01:17:57 -0000 X-NetworkBox-HamSign: 0101;OUT;wbeetaau1;749c9072445bf5f7e9134e3da2043220; Received: from mail.weatherbeeta.com.au (10.10.0.2) by network-box.weatherbeeta.com.au with SMTP; 25 Feb 2007 01:17:57 -0000 Received: (qmail 30063 invoked by uid 1166); 25 Feb 2007 12:17:57 +1100 Received: from 203.214.33.122 by mail.weatherbeeta.com.au (envelope-from , uid 1165) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.6/2315. perlscan: 1.25-st-qms. Clear:RC:0(203.214.33.122):. Processed in 0.51707 secs); 25 Feb 2007 01:17:57 -0000 X-Antivirus-mail.weatherbeeta.com.au-Mail-From: phillip.smith@weatherbeeta.com.au via mail.weatherbeeta.com.au X-Antivirus-mail.weatherbeeta.com.au: 1.25-st-qms (Clear:RC:0(203.214.33.122):. Processed in 0.51707 secs Process 30052) Received: from 203-214-33-122.dyn.iinet.net.au (HELO ?192.168.1.253?) (phillip.smith@weatherbeeta.com.au@203.214.33.122) by mail.weatherbeeta.com.au with SMTP; 25 Feb 2007 12:17:55 +1100 Subject: Re: Insert based in a select From: Phillip Smith Reply-To: phillip.smith@weatherbeeta.com.au To: Ezequias Rodrigues da Rocha Cc: pgsql-sql@postgresql.org In-Reply-To: <55c095e90702241606x4d15b7a9v5b084e575ef23140@mail.gmail.com> References: <55c095e90702241606x4d15b7a9v5b084e575ef23140@mail.gmail.com> Content-Type: multipart/alternative; boundary="=-+5t3WAvQY5JSRFq6HN/s" Organization: Weatherbeeta P/L Date: Sun, 25 Feb 2007 12:23:15 +1100 Message-Id: <1172366595.4925.10.camel@phillip-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 X-Scanned-By-wbeetaau1: Virus scan performed by network-box X-Scanned-By-wbeetaau1: Scanner file id is wbeetaau1-1172366277.406-21037-000 X-Scanned-By-wbeetaau1: No known viruses found in message (received+scanned in 0.04/0.22 secs) X-Scanned-By-wbeetaau1: Spam-Check-Result: No, hits=0 required=7 tests= autolearn=no version=2.0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.781 tagged_above=0 required=5 tests=BAYES_40, FORGED_RCVD_HELO, HTML_30_40, HTML_MESSAGE, RCVD_IN_SORBS_WEB X-Spam-Level: * X-Archive-Number: 200702/250 X-Sequence-Number: 27584 --=-+5t3WAvQY5JSRFq6HN/s Content-Type: text/plain Content-Transfer-Encoding: 7bit INSERT INTO second_table (master_id) SELECT id FROM master_table ORDER BY id; Was it important to you that the id and master id in the second table match up? ie, 1 and 10, 2 and 20, 3 and 30 - not 1 and 30, 2 and 10, 3 and 20 etc... ~p On Sat, 2007-02-24 at 21:06 -0300, Ezequias Rodrigues da Rocha wrote: > Hi list, > > Could someone help me with this problem > > I have a table like this > > Master table > > id number > 10 9898398398 > 20 9938378390 > 30 9873636736 > > and I want to make an insert into a table with this structure: > > Secondary table > > id(sequence), master_id > 1 10 > 2 20 > 3 30 > > It is possible to make this insert based in all records of my master table ? > > Any help would be very welcomed. > > Best Regards > Ezequias > > ---------------------------(end of broadcast)--------------------------- > TIP 7: You can help support the PostgreSQL project by donating at > > http://www.postgresql.org/about/donate *******************Confidentiality and Privilege Notice******************* The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email. Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments --=-+5t3WAvQY5JSRFq6HN/s Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit INSERT INTO second_table (master_id) SELECT id FROM master_table ORDER BY id;

Was it important to you that the id and master id in the second table match up? ie, 1 and 10, 2 and 20, 3 and 30 - not 1 and 30, 2 and 10, 3 and 20 etc...

~p

On Sat, 2007-02-24 at 21:06 -0300, Ezequias Rodrigues da Rocha wrote:
Hi list,

Could someone help me with this problem

I have a table like this

Master table

id number
10 9898398398
20 9938378390
30 9873636736

and I want to make an insert into a table with this structure:

Secondary table

id(sequence), master_id
1                    10
2                    20
3                    30

It is possible to make this insert based in all records of my master table ?

Any help would be very welcomed.

Best Regards
Ezequias

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

                http://www.postgresql.org/about/donate

*******************Confidentiality and Privilege Notice*******************

The material contained in this message is privileged and confidential to the addressee. If you are not the addressee indicated in this message or responsible for delivery of the message to such person, you may not copy or deliver this message to anyone, and you should destroy it and kindly notify the sender by reply email.

Information in this message that does not relate to the official business of Weatherbeeta must be treated as neither given nor endorsed by Weatherbeeta. Weatherbeeta, its employees, contractors or associates shall not be liable for direct, indirect or consequential loss arising from transmission of this message or any attachments
--=-+5t3WAvQY5JSRFq6HN/s--