X-Original-To: pgsql-sql@postgresql.org Received: from localhost (developer.postgresql.org [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 3180892597B for ; Mon, 26 May 2003 09:48:15 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 88799-01 for ; Mon, 26 May 2003 09:48:13 -0400 (EDT) Received: from mwinf0602.wanadoo.fr (smtp3.wanadoo.fr [193.252.22.25]) by developer.postgresql.org (Postfix) with ESMTP id 83EF392550B for ; Mon, 26 May 2003 09:48:13 -0400 (EDT) Received: from Paris (unknown [81.49.7.20]) by mwinf0602.wanadoo.fr (SMTP Server) with SMTP id CAD8154001A7 for ; Mon, 26 May 2003 15:48:12 +0200 (CEST) Reply-To: From: "Michael Mattox" To: Subject: How to delete multiple rows from multiple joined tables Date: Mon, 26 May 2003 15:48:16 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/496 X-Sequence-Number: 13661 I'm trying to use SQL to delete multiple rows from multiple tables that are joined together. From what I've seen delete can only delete from a single table, which is OK because I can just do separate deletes for each table. But the problem is how do I specify which rows to delete? For example: Table A is joined to Table B Table B is joined to Table C I want to delete all rows in table C & B that correspond to a row in Table A. Here's my exact SQL which actually deletes all the rows: delete from monitorstatusitemx where monitorx.namex='STRESS_TEST' and monitorstatusx.jdoidx = monitorstatus_statusitemsx.jdoidx and monitorstatus_statusitemsx.statusitemsx = monitorstatusitemlistd8ea58a5x.jdoidx and monitorstatusitemlistd8ea58a5x.statusitemlistx = monitorstatusitemx.jdoidx (It's a little ugly because I'm using JDO which generates the schema. Unfortunately deletes with JDO are very slow so I need to use SQL for this.) Michael