Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 850601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:17:21+00:00 2026-05-15T07:17:21+00:00

I´m trying to create a trigger on MySQL but I´m having a syntax problem,

  • 0

I´m trying to create a trigger on MySQL but I´m having a syntax problem, which I was not able to find. If someone more experience 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 !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:17:22+00:00Added an answer on May 15, 2026 at 7:17 am

    Thanks everyone … I´ve finaly solved it because of your help…

    In the end the work is:

    CREATE TRIGGER trg_delete_orphan_label AFTER DELETE ON restdb.service_descriptor
    FOR EACH ROW
    DELETE FROM restdb.labels
    WHERE id NOT IN (
    SELECT restdb.service_labels.id_label
    FROM restdb.service_labels );

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Not necessarily. Setting it to null, removes any references to… May 16, 2026 at 3:32 pm
  • Editorial Team
    Editorial Team added an answer You can do it using Criteria def criteria = Task.createCriteria()… May 16, 2026 at 3:32 pm
  • Editorial Team
    Editorial Team added an answer Make sure that the page you are redirecting to is… May 16, 2026 at 3:32 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to set up a MySQL trigger, but I can't figure out how
Im trying to create a function, that will return a mysql query, which i
I'm trying to use ON CASCADE DELETE in mysql db but I can't make
I am trying to write a stored procedure in MySQL which will perform a
I'm trying to create a trigger that monitor changes on a table and then
I've just wasted the past two hours of my life trying to create a
I'm trying to intercept any DELETE commands against a particular table. MySQL supports triggers
I am trying to write an automated test script for testing a MySQL Event
I'm trying to make an experimental web application which minimises redundant data. I have
I'm working with a system which had to create objects in one database based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.