X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4E7C88B9E85 for ; Sun, 6 Feb 2005 17:16:41 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34759-07 for ; Sun, 6 Feb 2005 17:16:17 +0000 (GMT) Received: from e2.ny.us.ibm.com (e2.ny.us.ibm.com [32.97.182.142]) by svr1.postgresql.org (Postfix) with ESMTP id CBEFF8B9B2B for ; Sun, 6 Feb 2005 17:16:16 +0000 (GMT) Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e2.ny.us.ibm.com (8.12.10/8.12.10) with ESMTP id j16HGF7J001968 for ; Sun, 6 Feb 2005 12:16:15 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay04.pok.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id j16HGFhD166190 for ; Sun, 6 Feb 2005 12:16:15 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11/8.12.11) with ESMTP id j16HGF3F016960 for ; Sun, 6 Feb 2005 12:16:15 -0500 Received: from d01ml255.pok.ibm.com (d01ml255.pok.ibm.com [9.56.227.128]) by d01av04.pok.ibm.com (8.12.11/8.12.11) with ESMTP id j16HGFJV016957 for ; Sun, 6 Feb 2005 12:16:15 -0500 Subject: Are JOINs allowed with DELETE FROM To: pgsql-performance@postgresql.org X-Mailer: Lotus Notes Release 6.0.2CF1 June 9, 2003 Message-ID: From: Steven Rosenstein Date: Sun, 6 Feb 2005 12:16:13 -0500 X-MIMETrack: Serialize by Router on D01ML255/01/M/IBM(Release 6.53HF103 | November 15, 2004) at 02/06/2005 12:16:14 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.262 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE X-Spam-Level: X-Archive-Number: 200502/92 X-Sequence-Number: 10421 This is probably a very trivial question and I feel foolish in even posting it, but I cannot seem to get it to work. SCENARIO (abstracted): Two tables, "summary" and "detail". The schema of summary looks like: id int serial sequential record id collect_date date date the detail events were collected The schema of detail looks like: id int serial sequential record id sum_id int the id of the parent record in the summary table details text a particular event's details The relationship is obvious. If I want to extract all the detail records for a particular date (2/5/05), I construct a query as follows: SELECT * FROM detail JOIN summary ON (summary.id=detail.sum_id) WHERE collect_date='2005-02-05'; Now... I want to *delete* all the detail records for a particular date, I tried: DELETE FROM detail JOIN summary ON (summary.id=detail.sum_id) WHERE collect_date='2005-02-05'; But I keep getting a parser error. Am I not allowed to use JOINs in a DELETE statement, or am I just fat-fingering the SQL text somewhere. If I'm *not* allowed to use a JOIN with a DELETE, what is the best workaround? I want to delete just the records in the detail table, and not its parent summary record. Thanks in advance for your help, --- Steve ___________________________________________________________________________________ Steven Rosenstein IT Architect/Developer | IBM Virtual Server Administration Voice/FAX: 845-689-2064 | Cell: 646-345-6978 | Tieline: 930-6001 Text Messaging: 6463456978 @ mobile.mycingular.com Email: srosenst @ us.ibm.com "Learn from the mistakes of others because you can't live long enough to make them all yourself." -- Eleanor Roosevelt