2

I am attempting to create a trigger to update quantities between 2 separate databases. This query runs successfully, but when I show triggers in mysql, it brings up an empty set. Any help would be much appreciated.

delimiter $$ CREATE TRIGGER `quantity_to_clb` AFTER UPDATE ON product 
FOR EACH ROW BEGIN UPDATE cl_boutique.product AS clb 
LEFT JOIN cherrylane.product AS cl 
ON clb.model = cl.code SET clb.quantity = cl.available
 WHERE clb.model = cl.code
 END $$ 
delimiter ;

1 Answer 1

2

That's because your code has two synax errors:

delimiter $$ --delimiter statements need to be on separate lines
CREATE TRIGGER `quantity_to_clb` AFTER UPDATE ON product 
FOR EACH ROW BEGIN 
  UPDATE cl_boutique.product AS clb 
  LEFT JOIN cherrylane.product AS cl 
  ON clb.model = cl.code SET clb.quantity = cl.available
   WHERE clb.model = cl.code; -- ; was needed here
END $$ 
delimiter ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.