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

  • SEARCH
  • Home
  • 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 6040011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:27:09+00:00 2026-05-23T06:27:09+00:00

I have a table that I want : when the table has been updated,

  • 0

I have a table that I want : when the table has been updated, 2 fields of that (title and description) change and take value from another table

This is my trigger:

drop trigger trigger_trade_request ;
CREATE TRIGGER trigger_trade_request AFTER UPDATE ON `trade_request` 
FOR EACH ROW 
BEGIN 

  IF NEW.title = null THEN

    UPDATE `trade_request_type`,`trade_request` 
       SET NEW.title = `trade_request_type`.title ,
           NEW.description = `trade_request_type`.description
     WHERE `trade_request_type`.id = NEW.trade_request_typeId;

  END IF;   
END;

My tables:

  • trade_request_type
  • trade_request

error:

ERROR 1442 : Can’t update table ‘trade_request’ in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

It does not work! What is the prob?

  • 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-23T06:27:10+00:00Added an answer on May 23, 2026 at 6:27 am
    1. Use is null to check for null values.
    2. To change the value of the updated row use BEFORE trigger and SET on the NEW row.

    Try this:

    CREATE TRIGGER trigger_update_request BEFORE UPDATE ON `trade_request`
    FOR EACH ROW
    BEGIN
        IF NEW.title IS NULL THEN
            SET NEW.title = (SELECT title FROM trade_request_type
                WHERE trade_request_type.id = NEW.trade_request_typeId);
            SET NEW.description = (SELECT description FROM trade_request_type
                WHERE trade_request_type.id = NEW.trade_request_typeId);
        END IF;
    END;
    

    Probably you can use the SELECT...INTO syntax instead of SET, like so:

    CREATE TRIGGER trigger_update_request BEFORE UPDATE ON `trade_request`
    FOR EACH ROW
    BEGIN
        IF NEW.title IS NULL THEN
            SELECT title, description
            FROM trade_request_type
            WHERE trade_request_type.id = NEW.trade_request_typeId
            INTO NEW.tile, NEW.description;
        END IF;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table in MySQL that has 3 fields and I want to
I have a table that contains some blob fields that I don't want to
I have a data table that is periodically updated by another service. I log
I have a dataset that has two tables in it. I want to do
Let's say that I want to have a table that logs the date and
On MS SQL Server 2005, I have a table that I want to replace.
I have a database table that i want to allow my friends to update.
I have a Database table that I want to display in a DataGridView. However,
I have a table that contains tasks and I want to give these an
I have a couple of triggers on a table that I want to keep

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.