> 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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql