我刚开始使用MySql中的程序。我已经阅读了很多关于如何实现它们的例子,但我的代码似乎没有用。这可能是非常简单的,在这种情况下,我为浪费你的时间道歉,我只是在黑暗中似乎是什么问题。
create PROCEDURE 'InsertFriends'('userId' int) CHARSET utf8
BEGIN
insert into movieton_friends (prim,sec)
select
M.usr_id, U.ID
from movieton_friends_map as M
inner join movieton_users as U
on M.fb_id = U.fb_id
left join movieton_friends as F
on F.usr_id = M.usr_id
and ( (M.usr_id = F.Prim and U.usr_id = F.Sec)
or (M.usr_id = F.Sec and U.usr_id = F.Prim))
where M.usr_id = userId and F.prim is NULL;
END
PhpMyadmin / Mysql抛出了这个错误:
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在''InsertFriends'('userId'int)附近使用正确的语法CHARSET utf8
BEGIN 插入第1行的movieton_frien'
一如既往,非常有帮助。
非常感谢您提供的任何提示,技巧或其他帮助!
PS:我在DELIMITER语句中尝试了几种变体,但实际上没有任何区别。我不能真正理解它是否需要,以及它对于这个主题的任何启示也是受欢迎的!答案 0 :(得分:1)
不使用引号或删除引号的反引号。
答案 1 :(得分:1)
该错误专门针对您在过程和变量名称周围使用的单引号:
create PROCEDURE 'InsertFriends'('userId' int) CHARSET utf8
在MySQL中,你应该在反引号时包围它们,而不是引号:
create PROCEDURE `InsertFriends`(`userId` int) CHARSET utf8