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

Поиск
Список
Период
Сортировка
От
Тема Re: DELETE FROM tableA WHERE NOT IN tableB ...
Дата
Msg-id Pine.LNX.4.10.10004180848520.29720-100000@picasso.realtyideas.com
обсуждение исходный текст
Ответ на DELETE FROM tableA WHERE NOT IN tableB ...  (The Hermit Hacker <scrappy@hub.org>)
Список pgsql-sql
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 
> 



В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: trouble with null
Следующее
От: "Ed"
Дата:
Сообщение: One query for two information...