| From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
|---|---|
| To: | Francisco Reyes <lists(at)stringsutils(dot)com> |
| Cc: | PostgreSQL general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Delete with subquery deleting all records |
| Date: | 2007-05-24 08:36:31 |
| Message-ID: | 46554E8F.3050401@magproductions.nl |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Francisco Reyes wrote:
> When I try to run:
> delete from export_messages where export_id in
> (SELECT distinct export_messages.export_id as id
> FROM export_messages
> LEFT OUTER JOIN exports ON (export_messages.export_id = exports.export_id)
> );
Why not use EXISTS?
DELETE FROM export_messages WHERE NOT EXISTS (
SELECT 1
FROM exports
WHERE exports.export_id = export_messages.export_id
)
I suppose you run those queries in a transaction block, right?
--
Alban Hertroys
alban(at)magproductions(dot)nl
magproductions b.v.
T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede
// Integrate Your World //
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Philippe Amelant | 2007-05-24 08:59:10 | Re: Tsearch2: upgrading from postgres 8.1.x to 8.2.x |
| Previous Message | Richard Huxton | 2007-05-24 08:20:55 | Re: [GENERAL] OIDs - file objects, are damaged by PostgreSQL. |