我正在尝试创建如下函数:
CREATE FUNCTION TitleToFileName(title varchar(200)) RETURNS varchar(200)
BEGIN
set title = REPLACE(title,":"," ");
set title=REPLACE(title,"/"," ");
set title=REPLACE(title,"_"," ");
RETURN title;
END
MySQL显示错误:
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本以使用正确的语法 在第3行的“”附近
我尝试使用'代替“和@title代替title,但是没有用。.
答案 0 :(得分:2)
$$
),而不是({;
)。DROP FUNCTION IF EXISTS
)DELIMITER
重新定义为;
尝试:
DELIMITER $$
DROP FUNCTION IF EXISTS `TitleToFileName`$$
CREATE FUNCTION TitleToFileName(title varchar(200)) RETURNS varchar(200)
BEGIN
set title = REPLACE(title,":"," ");
set title=REPLACE(title,"/"," ");
set title=REPLACE(title,"_"," ");
RETURN title;
END $$
DELIMITER ;