pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: kaiq@realtyideas.com
To: The Hermit Hacker <scrappy@hub.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: DELETE FROM tableA WHERE NOT IN tableB ...
Date: Tue, 18 Apr 2000 09:15:58 -0500 (CDT)
Message-ID: <Pine.LNX.4.10.10004180848520.29720-100000@picasso.realtyideas.com> (raw)
In-Reply-To: <Pine.BSF.4.21.0004181015390.226-100000@thelab.hub.org>

not tested:
delete from table_a         where not exists (select * from 
table_b where breferer = areferer)

tested:
select br_coid from brokers where not exists (select * from
coidinfo where c_coid = br_coid) 

Kai

On Tue, 18 Apr 2000, The Hermit Hacker
wrote
> 
> And now for todays trick question ...
> 
> have two tables, one of them is simple a string and a serial value, the
> second one is the serial value and more data ...
> 
> I want to clean out all records from tableB older then date (that is
> easy), then I want to clean out all values from tableB where there is no
> corresponding record in tableB ...
> 
> basically tableA's serial field is unique, but tableB's could have
> multiple records associated with. 
> 
> basically, what i've tried to do in a SELECT is something like:
> 
> SELECT referer_id 
>   FROM referer_data 
> EXCEPT 
>       SELECT distinct(referer_id) FROM referer_link;
> 
> But after 15 minutes, that's still running, so obviously that won't work ...
> 
> I can do it "in perl", but would love to come up with a nice, elegant, 'in
> server' method of doing this instead :)
> 
> Thanks...
> 
> Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
> Systems Administrator @ hub.org 
> primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 
> 




view thread (4+ messages)

Message-ID: <Pine.LNX.4.10.10004180848520.29720-100000@picasso.realtyideas.com>
Permalink:  ../Pine.LNX.4.10.10004180848520.29720-100000@picasso.realtyideas.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.10.10004180848520.29720-100000@picasso.realtyideas.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 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: kaiq@realtyideas.com, scrappy@hub.org
  Subject: Re: DELETE FROM tableA WHERE NOT IN tableB ...
  In-Reply-To: <Pine.LNX.4.10.10004180848520.29720-100000@picasso.realtyideas.com>
  References: <Pine.BSF.4.21.0004181015390.226-100000@thelab.hub.org> <Pine.LNX.4.10.10004180848520.29720-100000@picasso.realtyideas.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