Re: delete where not in another table - Mailing list pgsql-sql

From Marc Mamin
Subject Re: delete where not in another table
Date
Msg-id B6F6FD62F2624C4C9916AC0175D56D880CE095C2@jenmbs01.ad.intershop.net
Whole thread Raw
In response to Re: delete where not in another table  (Igor Neyman <ineyman@perceptron.com>)
List pgsql-sql
> 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);


Following query use an anti join and is much faster:
 delete from t1 where not exists (select user_id  from t2 where t2.user_id =t1.user_id )

regards,

Marc Mamin


pgsql-sql by date:

Previous
From: Gavin Flower
Date:
Subject: Re: DateDiff() function
Next
From: Stefan Sylla
Date:
Subject: update column based on postgis query on anther table