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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:29:31+00:00 2026-06-01T08:29:31+00:00

I have two tables: table A id | level_ID | col_m | col_n table

  • 0

I have two tables:

table A
 id | level_ID | col_m | col_n

table B
 id | prev_ID | cur_ID

table A is manipulated from the application layer where new inserts are done and updates as well. On the other hand table B has values inserted after an update only on level_ID column of table A via a trigger:

DELIMITER |
DROP TRIGGER IF EXISTS trigger_happy|
CREATE TRIGGER trigger_happy AFTER UPDATE ON table A
FOR EACH ROW
  BEGIN
    IF level_ID!=NEW.level_ID THEN
    INSERT INTO table B (id, cur_ID, prev_ID)
    VALUES (OLD.id, NEW.level_ID, OLD.level_ID)
  END IF;
END;
DELIMITER ;

The problem is that I intend to have the trigger only fire if there is a change in level_ID column. An update on other columns col_m and col_n should not fire the trigger.

Help me with my trigger statement, because it does not work as it is.

EDIT

Updates the columns are done at different times within the application logic. I need trigger to be fired ONLY when an update on level_ID is done.

  • 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-01T08:29:33+00:00Added an answer on June 1, 2026 at 8:29 am

    The solution I have found to work for me is as below:

    DELIMITER |
    DROP TRIGGER IF EXISTS trigger_happy|
    CREATE TRIGGER trigger_happy AFTER UPDATE ON table A
    FOR EACH ROW
      BEGIN
        IF NEW.level_ID!=OLD.level_ID THEN /* edit conditional statement */
        INSERT INTO table B (id, cur_ID, prev_ID)
        VALUES (OLD.id, NEW.level_ID, OLD.level_ID)
      END IF;
    END;
    | /* add delimiter */
    DELIMITER ;
    

    This trigger will only compare changes on the column level_ID and fire after an update. As I am using phpmyadmin, I had to specify the delimiter to |. I was leaving it at the default ;

    I hope this helps someone.

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

Sidebar

Related Questions

I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have two tables Table public.tags_to_entities Column | Type | Modifiers --------+---------+----------- tid |
I have two tables: Table items: | id | name | description | |
I have two tables (Table A, Table B) joined with a join table (TableAB)
I have two tables Table A type_uid, allowed_type_uid 9,1 9,2 9,4 1,1 1,2 24,1
Assume I have two tables: Table MY_ENTITY ID: PK OTHER_ID: FK to table OTHER
I have two tables : one table it matchs and the other is teams.
I have two tables: a source table and a target table. The target table
I have two tables, that share the same definition. I commonly insert new objects
I have the two tables below. The table jobs will have a user id

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.