Problems with mysql syntax
- by user368453
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 !