pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Darren Greer <dgreer@websightsolutions.com>
To: pgsql-sql@postgresql.org
Subject: Trouble with insert into.
Date: Fri, 18 Jun 1999 06:38:25 -0500
Message-ID: <9906180648350D.02503@george> (raw)

Hello all.  Lets say I have:
Table A (username text, first_name text, last_name text, zip int4)
Table B (username text, signupdate date, zip text)

In table A I have
user1	fred	jones	53125
user2	bob	smith	52145

In table B I have
user2	06/16/1999	52145

The way these tables were populated, table A and B were written to at the same
time.  However, table B, did not exist for the first 6 months of use.  So there
are many users who are in table A, that are not in table B.  

Now what I am tryign to do, is insert all users that dont exist in table B,
that exist in table A, into table B.  With o ne twist.  Signup date does not
exist in table A, so I need to insert them all with an arbitrary date.  I plan
on putting them all in as 04/15/1999.

Here is the select statement I was able to get to work:
	select l.username, l.zip
	from tableA l
	where not exists (
		select ld.username
		from tableB ld
		where ld.username = l.username
	);

Now my difficulty comes in inserting the data that is retrieved into table B.

If anyone can help me out, I would greatly appreciate it.  

Thanks,

Darren





view thread (2+ messages)  latest in thread

Message-ID: <9906180648350D.02503@george>
Permalink:  ../9906180648350D.02503@george/
Also on:    postgresql.org/message-id/9906180648350D.02503@george

 · 

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 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-sql@postgresql.org
  Cc: dgreer@websightsolutions.com
  Subject: Re: Trouble with insert into.
  In-Reply-To: <9906180648350D.02503@george>
  References: <9906180648350D.02503@george>

* 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