Are JOINs allowed with DELETE FROM

Поиск
Список
Период
Сортировка
От Steven Rosenstein
Тема Are JOINs allowed with DELETE FROM
Дата
Msg-id OF545A271F.B5FD775B-ON85256FA0.005EC116-85256FA0.005EDEB5@us.ibm.com
обсуждение исходный текст
Ответы Re: Are JOINs allowed with DELETE FROM
Re: Are JOINs allowed with DELETE FROM
Список pgsql-performance



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


В списке pgsql-performance по дате отправления:

Предыдущее
От: John A Meinel
Дата:
Сообщение: Re: query produces 1 GB temp file
Следующее
От: Tom Lane
Дата:
Сообщение: Re: query produces 1 GB temp file