有人知道我的sintaxys中有什么错误吗?
CREATE TRIGGUER safe_pass AFTER UPDATE ON usuario
FOR EACH ROW BEGIN
IF OLD.clave <> NEW.clave THEN
UPDATE usuario SET Clave = SHA1(MD5(NEW.clave)) WHERE id_usuario = NEW.id_usuario;
END IF;
END;
#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 'TRIGGUER safe_pass AFTER UPDATE ON usuario
FOR EACH ROW BEGIN
IF OLD.clave <' at line 1
我有使用 SQL Server 的经验,但 MySQL 让我很头疼。我拥有的 MySQL 版本是 MySQL Database Version 5.0.51b。
谢谢并恭祝安康
对不起,我真的很抱歉我的错误,我做了 Infinity 建议我的改变。
错误 SQL:
CREATE TRIGGER safe_pass AFTER UPDATE ON usuario
FOR EACH ROW BEGIN
IF OLD.clave <> NEW.clave THEN
UPDATE usuario SET Clave = SHA1( MD5( NEW.clave ) ) WHERE id_usuario = NEW.id_usuario
END IF;
END;
结果是:
#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 6
谢谢 Siride,我试试这个:
CREATE TRIGGER safe_pass AFTER UPDATE ON usuario
FOR EACH ROW BEGIN
IF OLD.clave <> NEW.clave THEN
UPDATE usuario SET Clave = SHA1( MD5( NEW.clave ) ) WHERE id_usuario = NEW.id_usuario;
END IF;
END;
结果是:
#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 '' at line 5
我必须从控制台执行此操作,最终脚本是:
DELIMITER //
CREATE TRIGGER safe_pass BEFORE UPDATE ON usuario
FOR EACH ROW BEGIN
IF OLD.clave <> NEW.clave THEN
SET NEW.clave = SHA1(MD5(NEW.clave));
END IF;
END;//
DELIMITER ;