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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:58:24+00:00 2026-06-15T08:58:24+00:00

I got the two following triggers, each one worked alone, but together they don’t.

  • 0

I got the two following triggers, each one worked alone, but together they don’t.

How can I make them to work together? They update different fields in table.

trigger 1:

create trigger wys_sk_u after update on `things`
for each row
begin
UPDATE `current` s 
INNER JOIN things u ON s.id_thing = u.id_thing
INNER JOIN dude_base b ON b.id= s.id
SET s.`curr_cash` = u.cash1 * b.cash2/ 100;
end;
$$

trigger 2:

create trigger suma_u after update on `current`
for each row
begin
UPDATE `current`
SET `mysum` = `curr_cash` + `mysum`;
end;
$$

First one should update when cash1 or cash2 updates, and change value of curr_cash.
Second should update when curr_cash updates, and change mysum.

I got following error when I edit table things:

#1442 - Can't update table 'current' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. 

@edit
added new answear to the question.


What if I want to do something like this:

CREATE TRIGGER total BEFORE UPDATE ON `current` FOR EACH ROW
BEGIN
if new.`new_pay_date` <> old.`new_pay_date`
  SET new.`total_cash` = new.`curr_cash` + new.`total_cash`;
end if;
END;
$$

Error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET new.`total_cash` = new.`curr_cash` + new.`total_cash`; end if;' at line 4

This was working without

if new.`new_pay_date` <> old.`new_pay_date`
end if;

But I need to check this, and only update with date change.

current table:

curr_cash
new_pay_date
id_person
id_thing
total_cash

Anyone can help me with this one?

  • 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-15T08:58:25+00:00Added an answer on June 15, 2026 at 8:58 am

    The problem is in the second trigger. Try to use BEFORE UPDATE trigger to change field value using SET statement –

    CREATE TRIGGER suma_u BEFORE UPDATE ON `current` FOR EACH ROW
    BEGIN
      SET new.`mysum` = new.`curr_cash` + new.`mysum`;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got the following two programs, one acting as a reader and the other
I'm having the following problem: When I got two labels into each other: <Label
i got following problem, i need to build a two checkboxes; where only one
so i have got two models with each one controller: Model Project has_many Themes
I have the following problem. I got two forms on my web page. On
So I've got some troubles with character encoding. When I put the following two
I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
I have the following problem: I got a view with two text fields and
I've got the following deadlock graph that describes two sql statements that are deadlocking
I got two data storages in my Windows Azure account. One is for the

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.