我要添加mysql函数:
CREATE FUNCTION `chf_get_translation`(translation_id INT, site_lang INT)
RETURNS text CHARSET utf8
BEGIN
DECLARE translation TEXT;
SELECT title
INTO translation
FROM chf_translations
WHERE key_id = translation_id
AND lang_id = site_lang;
RETURN translation;
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 3
最佳答案
尝试...
DELIMITER $$
CREATE FUNCTION `chf_get_translation`(translation_id INT, site_lang INT)
RETURNS text CHARSET utf8
BEGIN
DECLARE translation TEXT;
SELECT title
INTO translation
FROM chf_translations
WHERE key_id = translation_id
AND lang_id = site_lang;
RETURN translation;
END$$
关于mysql - 如何修复 MySQL CREATE FUNCTION 查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2967103/