Skip site navigation (1) Skip section navigation (2)

Re: DELETE FROM tableA WHERE NOT IN tableB ...

From: <kaiq(at)realtyideas(dot)com>
To: The Hermit Hacker <scrappy(at)hub(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: DELETE FROM tableA WHERE NOT IN tableB ...
Date: 2000-04-18 14:15:58
Message-ID: (view raw or whole thread)
Lists: pgsql-sql
not tested:
delete from table_a         where not exists (select * from 
table_b where breferer = areferer)

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


On Tue, 18 Apr 2000, The Hermit Hacker
> 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 
>       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 @ 
> primary: scrappy(at)hub(dot)org           secondary: scrappy(at){freebsd|postgresql}.org 

In response to

pgsql-sql by date

Next:From: EdDate: 2000-04-18 14:26:25
Subject: One query for two information...
Previous:From: Michael AnsleyDate: 2000-04-18 14:06:00
Subject: RE: DELETE FROM tableA WHERE NOT IN tableB ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group