Mysql创建触发器1064错误

发布于 2024-09-27 04:31:51 字数 765 浏览 3 评论 0原文

我写的sql

**delimiter |
CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id
END 
|
delimiter ;**

给出的错误

[SQL] 
**CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id
END 
;
[Err] 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 6**

如何解决?我的错误在哪里?

The sql i wrote

**delimiter |
CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id
END 
|
delimiter ;**

The error given

[SQL] 
**CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id
END 
;
[Err] 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 6**

How to solve this ? where is the mistake i do ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

儭儭莪哋寶赑 2024-10-04 04:31:51

看起来您只需要用分号终止 UPDATE 语句即可。

It looks like you simply need to terminate your UPDATE statement with a semicolon.

乄_柒ぐ汐 2024-10-04 04:31:51

试试这个代码

delimiter |
CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id;
END;|
delimiter ;

Try this code

delimiter |
CREATE 
DEFINER=CURRENT_USER 
TRIGGER set_profiletype_after_insert BEFORE INSERT ON trl_translator FOR EACH ROW 
BEGIN 
UPDATE trl_profile SET trl_profile.type = 'translator' WHERE trl_profile.profile_id = NEW.translator_id;
END;|
delimiter ;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文