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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:49:07+00:00 2026-05-26T02:49:07+00:00

I’m working with wordpress and need to create a trigger that updates a table

  • 0

I’m working with wordpress and need to create a trigger that updates a table when another is updated. I created the trigger and she worked in theory, but it only updates the first record and pause its execution. Variable used to store a select that returns would be one of ids separated by commas.

Eq: The select returns something like: 424,532,123,212

And use it within an update by putting “in”.

UPDATE wp_posts SET e.post_modified = date (NEW.modified_date) e.ID WHERE IN (@ids);

And as I said it updates only the first record in this case would be 424

I wish someone would help me.

Here is the trigger:

CREATE TRIGGER triggerupdatedata AFTER UPDATE ON wp_ngg_gallery
FOR EACH ROW BEGIN


    set @ids := (SELECT 
        GROUP_CONCAT(a.ID SEPARATOR ',') 
    FROM 
        wp_posts a, wp_postmeta b, wp_ngg_gallery c 
    WHERE 
        c.gid = OLD.gid 
    AND 
        a.ID = b.post_id 
    AND 
        b.meta_key = 'galeria_id' 
    AND 
        c.gid = (SELECT d.meta_value FROM wp_postmeta d WHERE d.post_id = a.ID AND d.meta_key = 'galeria_id')
    );

UPDATE wp_posts e SET e.post_modified = date(NEW.modified_date) WHERE e.ID IN (@ids);

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-05-26T02:49:08+00:00Added an answer on May 26, 2026 at 2:49 am

    I think you have been bitten by the anti-pattern called implicit join syntax.
    It causes all sorts of problems.
    Make your joins explicit so you don’t end up with cross join spaggeti.

    Also SQL and CSV do not mix.

    CREATE TRIGGER au_wp_ngg_gallery_each AFTER UPDATE ON wp_ngg_gallery FOR EACH ROW 
    BEGIN  
       UPDATE wp_posts e SET e.post_modified = date(NEW.modified_date) WHERE e.ID IN (
         SELECT * FROM (
       SELECT a.id  
       FROM wp_posts p
       INNER JOIN wp_postmeta pm ON  (pm.post_id  = p.id AND pm.meta_key  = 'galeria_id')
       INNER JOIN wp_postmeta pm2 ON (pm2.post_id = p.id AND pm2.meta_key = 'galeria_id')
       /* not sure if the join on pm2 is needed or not */
       INNER JOIN wp_ngg_gallery ng ON (ng.gid = pm2.meta_value)
       WHERE 
          ng.gid = OLD.gid ) sub) subsubhack); 
    END // 
    

    You cannot update a table and select from the same table in a subselect.

    But you can update a table and select from the same table in a sub-sub-select.
    The reason is that a sub-sub-select is forced to run prior to the update, whereas a ‘mere’ subselect can run concurrent with the update, which would cause all sorts of problems.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need to clean up various Word 'smart' characters in user input, including but
I have thousands of HTML files to process using Groovy/Java and I need to

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.