Problems with mysql syntax
Posted
by user368453
on Stack Overflow
See other posts from Stack Overflow
or by user368453
Published on 2010-06-17T14:00:23Z
Indexed on
2010/06/17
14:03 UTC
Read the original article
Hit count: 133
Hello everyone !!
I´m trying to create a trigger on MySQL but I´m having a sintaxe problem, which I was not able to find. If someone more experient could help me it would be great (it´s the first time I use MySQL!)...
The reason why I´m creating this trigger is for deleting all the orphan "labels", which has a many-to-many relation with "service_descriptor" (this two entities are linked by service_labels).
The code I have is:
CREATE TRIGGER trg_delete_orphan_label
AFTER DELETE FOR EACH ROW ON restdb
.service_labels
DELETE
FROM
restdb
.labels
WHERE
EXISTS (SELECT
*
FROM
old D LEFT_JOIN
restdb
.service_labels
SL ON
SL.id_label
= D.id_label
AND
D.id_service
= SL.id_service
WHERE
SL.id_label
IS NULL
restdb
.labels
.id
= D.SL.id_label
);
Thanks in advance !
© Stack Overflow or respective owner