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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:42:20+00:00 2026-05-15T16:42:20+00:00

I have a simple question. Ive got a trigger to insert the values into

  • 0

I have a simple question. Ive got a trigger to insert the values into another Database

So for example if there are two values and the trigger is checking the value in Table A and inserting into Table B

So here is the code

-- Trigger DDL Statements
USE `db`;
DELIMITER //

CREATE
DEFINER=CURRENT_USER()
TRIGGER `db`.`AFTER_INSERT_A`
AFTER INSERT ON `db`.`a`
FOR EACH ROW
BEGIN

    IF NEW.val!= NULL
    THEN

        UPDATE b SET dateRemove=CURRENT_TIMESTAMP WHERE val=NEW.val;

        INSERT INTO b (val) VALUES(NEW.val) ON DUPLICATE KEY UPDATE dateRemove=NULL, dateUpdate=CURRENT_TIMESTAMP;

    END IF;
END//

The trigger dosent even throw any errors. And i have no values in B

My Insert is

INSERT INTO a (val) VALUES(`test`) ON DUPLICATE KEY UPDATE dateUpdate=CURRENT_TIMESTAMP

Has any one got any ideas. Ive tried creating two triggers one INSERTand the other UPDATE, Ive changed the AFTER to BEFORE and my table b still got nothing. Any ideas 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-15T16:42:21+00:00Added an answer on May 15, 2026 at 4:42 pm

    The trigger to be run on a query such as

    INSERT INTO table (x, y, z) VALUES('x', 'y', 'z') ON DUPLICATE KEY UPDATE x=VALUES(x);
    

    must always be run on a BEFORE INSERT Trigger.

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

Sidebar

Related Questions

I've got two PC's, but both have another IP. The simple question is how
i have a simple question, there is a function with parameter emp_id that opens
I've got (probably) a simple question. When do I have to declare a function
I've got what is hopefully a simple question - I've got two entities -
I've got a simple question for you :) I have the following Scala code,
I have a simple question, and hopefully there is a simple answer . .
Simple question that i've always pondered about. When I first got into opengl I
I've got a simple question. In Objective-C, when you have a method you want
I've got a basic question about obj-c coding, say I have two classes represented
I've only have a simple question to ask : Is it possible to call

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.