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/