This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use triggers on mysql - query produce error

 
Peter Primrose
Ranch Hand
Posts: 755
  • 0
  • 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
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic