0

I'm writing a SQL trigger to whenever update the (engage_step_user_response) table (response_json) column after updated. I need to increase no of retakes that I included same table as a column. This is the trigger i have wrote. Can anyone please help with this

CREATE TRIGGER increment_engage
BEFORE UPDATE OF response_json
ON engage_step_user_response
FOR EACH ROW
SET NEW.retakes = OLD.retakes + 1;

Error Code: 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 'OF response_json ON engage_step_user_response FOR EACH ROW SET NEW.retakes = OLD' at line 2 0.000 secenter image description here

6
  • What is the problem? Some error message? retakes is not changed? What?
    – Rick James
    Jan 31, 2023 at 5:53
  • retakes changed before I update that query. But then I added "OF response_json" to the query because i need to change retakes after update "response_json" coulmn
    – david_23
    Jan 31, 2023 at 6:02
  • Please pist table schema Jan 31, 2023 at 6:05
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Jan 31, 2023 at 6:06
  • my goal is to whenever "response_json" column has been updated the no of retakes increase by one. for achieve that i need to write a sql trigger.
    – david_23
    Jan 31, 2023 at 6:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.