Re: Delete with subquery deleting all records
- From: Francisco Reyes <lists(at)stringsutils(dot)com>
- To: Alban Hertroys <alban(at)magproductions(dot)nl>
- Cc: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
- Subject: Re: Delete with subquery deleting all records
- Date: Thu, 24 May 2007 20:20:42 -0400
- Message-id: <cone(dot)1180052442(dot)281492(dot)39101(dot)5001(at)35st(dot)simplicato(dot)com>
Alban Hertroys writes:
Why not use EXISTS?
DELETE FROM export_messages WHERE NOT EXISTS (
SELECT 1
FROM exports
WHERE exports.export_id = export_messages.export_id
)
Didn't think of it. Thanks for the code.
I suppose you run those queries in a transaction block, right?
Correct.
Also I do a backup before doing the deletions.
Home |
Main Index |
Thread Index