X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 752A39DCC53 for ; Wed, 8 Feb 2006 14:11:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05826-01 for ; Wed, 8 Feb 2006 14:11:27 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from outbound.internet-mail-service.net (outbound6.internet-mail-service.net [216.240.47.197]) by postgresql.org (Postfix) with ESMTP id 505389DCC22 for ; Wed, 8 Feb 2006 14:11:26 -0400 (AST) Received: from idiom.com (idiom.com [216.240.32.1]) by outbound.internet-mail-service.net (Postfix) with ESMTP id 40C9423FE06; Wed, 8 Feb 2006 10:11:26 -0800 (PST) Received: from [192.168.1.109] (adsl-69-107-112-198.dsl.pltn13.pacbell.net [69.107.112.198]) by idiom.com (8.12.11/8.12.11) with ESMTP id k18IBOvi008262; Wed, 8 Feb 2006 10:11:25 -0800 (PST) (envelope-from bryce1@obviously.com) Message-ID: <43EA3445.9050401@obviously.com> Date: Wed, 08 Feb 2006 10:11:17 -0800 From: Bryce Nesbitt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org CC: Markus Schaber Subject: Re: Delete with join -- deleting related table entries? References: <144D12D7DD4EC04F99241498BB4EEDCC20CC56@nelson.osl.com> <43EA2D5D.6000304@obviously.com> <43EA3082.1010804@logix-tt.com> In-Reply-To: <43EA3082.1010804@logix-tt.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.103 required=5 tests=[AWL=0.103] X-Spam-Score: 0.103 X-Spam-Level: X-Archive-Number: 200602/81 X-Sequence-Number: 24091 Markus Schaber wrote: > Hi, Bryce, > > Bryce Nesbitt wrote: > > >> BEGIN; >> DELETE FROM note WHERE issue_id IN (SELECT issue_id FROM isuse >> WHERE reservation_id IN >> (select reservation_id from reservations where date > magic) >> ); >> DELETE FROM isuse WHERE reservation_id IN >> (select reservation_id from reservations where date > magic); >> DELETE FROM reservations WHERE reservation_id IN >> (select reservation_id from reservations where date > magic); >> COMMIT; >> >> I suppose I can do the subselect as a perl wrapper, but I was thinking >> that maybe SQL could do it all for me.... >> > > Why do you think this won't work? (provided you add the missing ) and ; :-) > Wow. It worked. Cool. I guess the reservations don't get deleted until they are not needed any more... Not the fastest thing in the world. But it worked.