Re: Are JOINs allowed with DELETE FROM

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Steven Rosenstein <srosenst(at)us(dot)ibm(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Are JOINs allowed with DELETE FROM
Date: 2005-02-06 17:50:29
Message-ID: 20050206175029.GA89095@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sun, Feb 06, 2005 at 12:16:13PM -0500, Steven Rosenstein wrote:
>
> 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.

See the documentation for DELETE:

http://www.postgresql.org/docs/8.0/static/sql-delete.html

If you intend to delete the date's record from the summary table,
then the detail table could use a foreign key constraint defined
with ON DELETE CASCADE. Deleting a record from summary would then
automatically delete all associated records in detail.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message John Arbash Meinel 2005-02-06 17:58:45 Re: Are JOINs allowed with DELETE FROM
Previous Message Gaetano Mendola 2005-02-06 17:36:03 Re: Are JOINs allowed with DELETE FROM