Re: delete where not in another table

Поиск
Список
Период
Сортировка
От Igor Neyman
Тема Re: delete where not in another table
Дата
Msg-id A76B25F2823E954C9E45E32FA49D70EC1BBDB24E@mail.corp.perceptron.com
обсуждение исходный текст
Ответ на delete where not in another table  ("Campbell, Lance" <lance@illinois.edu>)
Ответы Re: delete where not in another table  (Marc Mamin <M.Mamin@intershop.de>)
Список pgsql-sql
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Campbell, Lance
Sent: Tuesday, July 09, 2013 3:25 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] delete where not in another table

 
DELETE FROM T1 WHERE T1.user_id NOT IN (SELECT user_id FROM T2 WHERE T2.user_id=T1.user_id);
 
Thanks,
 
Lance Campbell
Software Architect
Web Services at Public Affairs
217-333-0382

  --
Try:

DELETE  FROM t1   USING t2  WHERE t1.user_id != t2.user_id;

Test it before running on production db.

Regards,
Igor Neyman
 



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

Предыдущее
От: "Campbell, Lance"
Дата:
Сообщение: delete where not in another table
Следующее
От: Huan Ruan
Дата:
Сообщение: DateDiff() function