pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Phillip Smith <phillip.smith@weatherbeeta.com.au>
To: Ezequias Rodrigues da Rocha <ezequias.rocha@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Insert based in a select
Date: Sun, 25 Feb 2007 12:23:15 +1100
Message-ID: <1172366595.4925.10.camel@phillip-desktop> (raw)
In-Reply-To: <55c095e90702241606x4d15b7a9v5b084e575ef23140@mail.gmail.com>
References: <55c095e90702241606x4d15b7a9v5b084e575ef23140@mail.gmail.com>

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

view thread (6+ messages)  latest in thread

Message-ID: <1172366595.4925.10.camel@phillip-desktop>
Permalink:  ../1172366595.4925.10.camel@phillip-desktop/
Also on:    postgresql.org/message-id/1172366595.4925.10.camel@phillip-desktop

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: phillip.smith@weatherbeeta.com.au, ezequias.rocha@gmail.com
  Subject: Re: Insert based in a select
  In-Reply-To: <1172366595.4925.10.camel@phillip-desktop>

* 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