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 8014501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:57:13+00:00 2026-06-04T19:57:13+00:00

I had to restore a table from a backed-up version of that table. Then

  • 0

I had to restore a table from a backed-up version of that table. Then I went to recreate the triggers. I can’t get one re-created. I’ve looked at some examples of how this sort of trigger should look nothing here glares at me. I copied it from the code showed in phpmyadmin when i clicked “change” on the old trigger to save it. I thought that would be foolproof!

1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 5

CREATE TRIGGER `trig_parts_price_AfterUpdate` AFTER UPDATE ON `parts`
    FOR EACH ROW BEGIN
       IF (NEW.cost <> OLD.cost || NEW.price <> OLD.price || NEW.QtyInStock <> OLD.QtyInStock) THEN
          INSERT INTO `inv_hist_simple` (sku, cost, price, QtyInStock, change_date) 
          VALUES(OLD.sku_m, NEW.cost, NEW.price, NEW.QtyInStock, NOW());
    END IF;
END;
  • 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-04T19:57:15+00:00Added an answer on June 4, 2026 at 7:57 pm

    Put this line above your code:

    DELIMITER $$
    

    and change the last line of your code to

    END $$
    

    Then add this line at the end:

    DELIMITER ;
    

    Otherwise the ; tells the server, that the code for the trigger finishes after your insert statement, which is causing the syntax error.

    So it basically should look like this:

    DELIMITER $$
    CREATE TRIGGER `trig_parts_price_AfterUpdate` AFTER UPDATE ON `parts`
        FOR EACH ROW BEGIN
           IF (NEW.cost <> OLD.cost || NEW.price <> OLD.price || NEW.QtyInStock <> OLD.QtyInStock) THEN
              INSERT INTO `inv_hist_simple` (sku, cost, price, QtyInStock, change_date) 
              VALUES(OLD.sku_m, NEW.cost, NEW.price, NEW.QtyInStock, NOW());
        END IF;
    END $$
    DELIMITER ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Had a good search here but can't see anything that gets my mind in
Wednesday I had to restore from a back-up image I made on Monday. At
We have a postgresql database that is backed up nightly from a cron job
I had some problems with my subversion server and i had to restore it
Had a page that was working fine. Only change I made was to add
Had a problem with the recursive conflictCheck() method. That seems fine now. I have
Had this working; at one stage. The problem is the following text is now
I had this problem before and can't for life of me remember how to
In SQL Server 2008, I have my parent table in one database, and the
I have a single row of data in a SQL Server table that I'm

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.