• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use triggers on mysql - query produce error

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Can anyone advise why this sql statement is incorrect?
I'm trying to learn how to use triggers on mysql



I get:
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 'where car_id='6723' )
THEN
UPDATE cars set car_n

* using mysql version: 5.0.45-community-nt
 
Paul Campbell
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea why you'd want to use a trigger for something this specific... but something more like this:

CREATE TRIGGER T1
AFTER UPDATE ON cars
FOR EACH ROW
BEGIN
IF (fax_number='555555' and car_id='6723') THEN
set car_name = 'test';
END IF;
END;

If the columns you are testing for are being updated... you will new to use NEW/OLD depending on your test state.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!