Re: Insert based in a select - Mailing list pgsql-sql

From Phillip Smith
Subject Re: Insert based in a select
Date
Msg-id 1172366595.4925.10.camel@phillip-desktop
Whole thread Raw
In response to Insert based in a select  ("Ezequias Rodrigues da Rocha" <ezequias.rocha@gmail.com>)
List pgsql-sql
INSERT INTO second_table (master_id) SELECT id FROM master_table ORDER BY id;<br /><br /> Was it important to you that
theid 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...<br/><br /> ~p<br /><br /> On Sat, 2007-02-24 at 21:06 -0300, Ezequias Rodrigues da Rocha wrote: <blockquote
type="CITE"><pre>
<font color="#000000">Hi list,</font>

<font color="#000000">Could someone help me with this problem</font>

<font color="#000000">I have a table like this</font>

<font color="#000000">Master table</font>

<font color="#000000">id number</font>
<font color="#000000">10 9898398398</font>
<font color="#000000">20 9938378390</font>
<font color="#000000">30 9873636736</font>

<font color="#000000">and I want to make an insert into a table with this structure:</font>

<font color="#000000">Secondary table</font>

<font color="#000000">id(sequence), master_id</font>
<font color="#000000">1                    10</font>
<font color="#000000">2                    20</font>
<font color="#000000">3                    30</font>

<font color="#000000">It is possible to make this insert based in all records of my master table ?</font>

<font color="#000000">Any help would be very welcomed.</font>

<font color="#000000">Best Regards</font>
<font color="#000000">Ezequias</font>

<font color="#000000">---------------------------(end of broadcast)---------------------------</font>
<font color="#000000">TIP 7: You can help support the PostgreSQL project by donating at</font>

<font color="#000000">                <a
href="http://www.postgresql.org/about/donate">http://www.postgresql.org/about/donate</a></font>
</pre></blockquote><br /><p><b>*******************Confidentiality and Privilege Notice*******************</b><p> The
materialcontained in this message is privileged and confidential to the addressee. If you are not the addressee
indicatedin this message or responsible for delivery of the message to such person, you may not copy or deliver this
messageto anyone, and you should destroy it and kindly notify the sender by reply email. <p> Information in this
messagethat 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
consequentialloss arising from transmission of this message or any attachments <br /> 

pgsql-sql by date:

Previous
From: "Ezequias Rodrigues da Rocha"
Date:
Subject: Insert based in a select
Next
From: "Rodrigo De León"
Date:
Subject: Re: Change a field to sequence (serial)