创建函数时MySql查询出错

时间:2014-11-14 13:50:59

标签: php mysqli compiler-errors

如何解决这个问题, 我在查询

后执行此操作时遇到错误
 $mysql_function_query  =   "DROP FUNCTION IF EXISTS EXPLODE_STRING;
                                DELIMITER $$
                                CREATE FUNCTION EXPLODE_STRING(str VARCHAR(255), delim VARCHAR(12), pos INT)
                                    RETURNS INT
                                    BEGIN
                                    RETURN  REPLACE(SUBSTRING(SUBSTRING_INDEX(str, delim, pos),
                                                    LENGTH(SUBSTRING_INDEX(str, delim, pos-1)) + 1),delim, '');
                                    END;
                                    $$
                                    DELIMITER ;";


     mysqli_query($link,$mysql_function_query) or die(mysqli_error($link));

显示的错误是

 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 
'DELIMITER $$ CREATE FUNCTION EXPLODE_STRING(str VARCHAR(255), delim VA' at line 2

0 个答案:

没有答案