Subject | Re: delete and join syntax |
---|---|
Author | mmenaz |
Post date | 2002-04-23T22:44:02Z |
As I wrote:
With delete this does not work.
I've found a workaround like:
DELETE FROM PROGRESSIVI_CONTABILI
WHERE EXISTS (SELECT * FROM PROGRESSIVI_CONTABILI
INNER JOIN UNITA_U_CLIENTI ON (PROGRESSIVI_CONTABILI.ESERCIZIO_ID = UNITA_U_CLIENTI.ESERCIZIO_ID)
INNER JOIN UNITA_IMMOBILIARI ON (UNITA_U_CLIENTI.UNITAIMM_ID = UNITA_IMMOBILIARI.UNITAIMM_ID)
INNER JOIN PROGRESSIVI_CONTABILI ON (UNITA_IMMOBILIARI.CONDOMINIO_ID = PROGRESSIVI_CONTABILI.CONDOMINIO_ID)
WHERE (CONDOMINIO_ID=UNITA_IMMOBILIARI.CONDOMINIO_ID) AND
(ESERCIZIO_ID=OLD.ESERCIZIO_ID) AND
(CONTO_ID=OLD.UICC_ID));
Is this the only, correct way of doing things with delete? Or is there a join syntax for that purpouse? Searching google I've found that syntax used, but I don't know if were good advices or not ;)
Thanks
Regards
Marco Menardi
> At 12:16 PM 23-04-02 +0000, Marco Menardi wrote:I want to delete from ONE TABLE (PROGRESSIVI_CONTABILI), but the where clause needs to check some fields that are not in that table. In that table there are foreign keys to tables where those fields are. So, for a select, I would have used a join just to have those fields available for the WHERE clause.
> >Hi, I'm trying to delete from a table using criterion from a join,
With delete this does not work.
I've found a workaround like:
DELETE FROM PROGRESSIVI_CONTABILI
WHERE EXISTS (SELECT * FROM PROGRESSIVI_CONTABILI
INNER JOIN UNITA_U_CLIENTI ON (PROGRESSIVI_CONTABILI.ESERCIZIO_ID = UNITA_U_CLIENTI.ESERCIZIO_ID)
INNER JOIN UNITA_IMMOBILIARI ON (UNITA_U_CLIENTI.UNITAIMM_ID = UNITA_IMMOBILIARI.UNITAIMM_ID)
INNER JOIN PROGRESSIVI_CONTABILI ON (UNITA_IMMOBILIARI.CONDOMINIO_ID = PROGRESSIVI_CONTABILI.CONDOMINIO_ID)
WHERE (CONDOMINIO_ID=UNITA_IMMOBILIARI.CONDOMINIO_ID) AND
(ESERCIZIO_ID=OLD.ESERCIZIO_ID) AND
(CONTO_ID=OLD.UICC_ID));
Is this the only, correct way of doing things with delete? Or is there a join syntax for that purpouse? Searching google I've found that syntax used, but I don't know if were good advices or not ;)
Thanks
Regards
Marco Menardi