用的MYSQL 5.0
想吧表中某值的旧值和新值差加到另一张表中的某个字段中去。//这一步还没写到,麻烦有心人给个提示
但是写触发器的时候总是报错。不知道为什么。请大家帮忙看看。
一下两段代码都只是先写出来做下测试的,但是有问题。
CREATE TRIGGER update_position
AFTER UPDATE on position_tb FOR EACH ROW
BEGIN
IF (NEW.score <> OLD.score) THEN SELECT * FROM position_tb;
ELSE
SELECT * FROM class_tb;
END IF;
END;
错误:
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 'SELECT * FROM position_tb' at line 4
(0 ms taken)
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 'ELSE
SELECT * FROM class_tb' at line 1
(0 ms taken)
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 'END IF' at line 1
(0 ms taken)
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 'END' at line 1
(0 ms taken)
CREATE TRIGGER update_position
AFTER UPDATE on position_tb FOR EACH ROW
BEGIN
select * from position_tb;
END;
错误:
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 'select * from position_tb' at line 4
(0 ms taken)
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 'END' at line 1
(0 ms taken)