pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: filippo2991@virgilio.it
To: pgsql-sql@postgresql.org
Subject: insert related data into two tables
Date: 14 May 2006 14:40:49 -0700
Message-ID: <1147642849.180115.107460@u72g2000cwu.googlegroups.com> (raw)

Hello,

I have two tables like these:

TABLE_1:  people registry
fields: ID_T1, SURNAME, NAME
ID_T1 is primary key

TABLE_2: work groups
fields: ID_T2, TASK
ID_T2 is foreign key related to ID_T1

the first table is the list of employees, the second the task.

Sometime I need to insert a new employee and at the same time the task
for him:
I want to INSERT TO table 1 JOHN DOE (the ID is assigned automatically
since it's a primary key) and INSERT TO table 2 the ID and the task
name for JOHN DOE. Is it possible to create a single query? What is the
best way to do this?

Thanks,

Filippo




view thread (3+ messages)  latest in thread

Message-ID: <1147642849.180115.107460@u72g2000cwu.googlegroups.com>
Permalink:  ../1147642849.180115.107460@u72g2000cwu.googlegroups.com/
Also on:    postgresql.org/message-id/1147642849.180115.107460@u72g2000cwu.googlegroups.com

 · 

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: filippo2991@virgilio.it
  Subject: Re: insert related data into two tables
  In-Reply-To: <1147642849.180115.107460@u72g2000cwu.googlegroups.com>

* 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