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

  • SEARCH
  • Home
  • 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 8460475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:37:06+00:00 2026-06-10T13:37:06+00:00

I am unable to get the following code to work, using this page for

  • 0

I am unable to get the following code to work, using this page for reference as well as of other posts on this site. I need to create a trigger that will insert a record in Table B whenever Table A is updated. The code below shows what I am attempting; however this produces a syntax error (#1064). I am also unclear on if I need to include the ‘DELIMITER $$’ syntax or not. I appreciate your help

DELIMITER $$
CREATE TRIGGER MyTrigger
AFTER INSERT
ON TableA
FOR EACH ROW 
BEGIN
    INSERT INTO TableB SET 
    TableA_id = NEW.TableB_id, 
    TableA_date = NEW.TableB_date,
    TableA_comment = NEW.TableB_comment;
  END;
END $$
DELIMITER ;

EDIT: in the pseudo-code above I am using a $TableName_$FieldName convention to indicate that Column A belongs to Table A, Column B belongs to Table B. I should have made that more clear in my original question. Someone commented below I have the NEW indicator on the wrong side (should be on Table A), but that comment appears to have been removed. Can someone please confirm? Thanks for all your help

  • 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-06-10T13:37:07+00:00Added an answer on June 10, 2026 at 1:37 pm

    Try this:

    DELIMITER $$
    CREATE TRIGGER MyTrigger
    AFTER INSERT
    ON TableA
    FOR EACH ROW 
    BEGIN
        INSERT INTO TableB SET 
        TableB_id = NEW.TableA_id, 
        TableB_date = NEW.TableA_date,
        TableB_comment = NEW.TableA_comment;
    END $$
    DELIMITER ;
    

    The DELIMITER here is used to tell mysql to treat all the following ; as part of the definition instead of actual command terminations.

    Notice that I removed an unmatched END; just before the closing END $$

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

Sidebar

Related Questions

I'm unable to get this jquery statement to work on page load but it
I have the following code and I am still unable to get Hibernate to
I'm using this code to download the timeline page from our local Trac system:
I'm trying to get the following bit of code to work in LINQPad but
I can't get it to work. i get the following: Unable to find matching
When I compile my application , I get following compile error. Unable to find
I'm unable to get the length of the following JSON array object. Actually I
I cannot compile python in pydev in eclipse. I get the following error: unable
I am unable to get the correct title for this, please change the title
I am unable to get a Javascript callback to work with gmaps4_rails when the

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.