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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:33:19+00:00 2026-05-20T00:33:19+00:00

I’ve a very simple database with following schema: video (id, title, description) category (id,

  • 0

I’ve a very simple database with following schema:

video (id, title, description)
category (id, name)
tag (id, name)

video_category_reference (video_id, category_id)
video_tag_reference(video_id, tag_id)

abc_table (video_id, description, categories)

The first five tables use InnoDB engine.

The last table – abc_table uses MyISAM engine and it contains some kind of “cache”. description column stores the result of CONCAT(video.title, video.description, GROUP_CONCAT(tag.name)) and categories column stores the result of GROUP_CONCAT(category.id).

What I need is a trigger that will populate abc_table after a new video is created. A new video will be created always the same way:

START TRANSACTION;

INSERT INTO video VALUES(NULL, "My video", "description");

SET @vid = (SELECT LAST_INSERT_ID());

INSERT INTO video_category_reference VALUES (@vid, 1), (@vid, 2), (@vid, 3), (@vid, 4);
INSERT INTO video_tag_reference VALUES (@vid, 5), (@vid, 6), (@vid, 7), (@vid, 8);

COMMIT;

Unfortunately I can’t use this trigger:

CREATE TRIGGER after_insert_on_video AFTER INSERT ON video FOR EACH ROW BEGIN
    SET @categories = (SELECT GROUP_CONCAT(category_id) FROM video_category_reference WHERE video_id = NEW.id GROUP BY video_id);
    SET @tags = (SELECT GROUP_CONCAT(t.name) FROM video_tag_reference vtr JOIN tag t ON vtr.tag_id = t.id WHERE video_id = NEW.id GROUP BY video_id);

    INSERT INTO video_search_table VALUES (NEW.id, CONCAT(NEW.title, NEW.raw_description, @tags), @categories);
END$$

…as it will be executed before inserts on *_reference tables will be done.


Is there any way I could force MySQL to execute a trigger after the transaction is commited? Or do I have to create triggers for *_referemce tables that will modify values in abc_table?

  • 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-20T00:33:19+00:00Added an answer on May 20, 2026 at 12:33 am

    You could change your trigger to AFTER UPDATE and have a quick:

    UPDATE video SET id=@vid WHERE id=@vid;
    

    to trigger the trigger before the transaction ends. Bonus: if your video information is updated, the trigger runs again =D.

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

Sidebar

Related Questions

No related questions found

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.