0

I'm new to the php mysql developpement, I want to make a trigger to be launched after I insert a row in the evolution table. The trigger must take a value (prixMisDaccord) from another table (inscription) and reduce it value from the evolution column prixAPaye.

Here is what I tried and what I found on Stack Overflow:

DELIMITER $$
CREATE TRIGGER trg_rap
BEFORE INSERT ON evolution FOR EACH ROW
BEGIN
       DECLARE pmd float;
       -- Check BookingRequest table
       SELECT prixMisDaccord
       INTO @pmd
       FROM inscription
       WHERE inscription.idETD= 1;

    
           
           SET NEW.resteAPaye = @pmd-NEW.prixPaye
           WHERE idETD = 1;
        
END;
$$
DELIMITER `;
Chris Haas
  • 53,986
  • 12
  • 141
  • 274
MOÂAD
  • 1
  • And what's wrong with your trigger? – Shadow Jan 28 '23 at 15:16
  • *The trigger must take a value (prixMisDaccord) from another table (inscription) and reduce it value from the evolution column prixAPaye.* Show this on an example. See [Tips for asking a good Structured Query Language (SQL) question](//meta.stackoverflow.com/questions/271055) – Akina Jan 28 '23 at 16:26
  • The trigger doesn't work i can't even create it it says that i have a probleme from this line SELECT prixMisDaccord – MOÂAD Jan 28 '23 at 16:52

1 Answers1

0

'i have a probleme from this line SELECT' - Is not the error I get, I do get an error on the set statement because you cannot apply a where clause to a set..There are other problems with your code and you don't seem to know the difference between user defined variables and declared variables see - How to declare a variable in MySQL? and temporary tables..so @pmd-NEW.prixPaye is just nonsense.

If you want more help read https://stackoverflow.com/help/how-to-ask and provide table definitions,sample data and desired outcome all as text in the question.

P.Salmon
  • 17,104
  • 2
  • 12
  • 19