首页 > 解决方案 > 插入mysql自定义变量后值会改变

问题描述

我正在研究mysql自定义功能。我创建了以下新功能代码:

CREATE DEFINER=`root`@`%` FUNCTION `getNewLogicPassFailStatus`(Id varchar(20),subject1 varchar(520)) RETURNS INT
DETERMINISTIC
BEGIN
    select MAX(writenscore) into @writtenscore from exam.marks WHERE Id =ID and subject = subject1;

    return @writtenscore;
END

没有发现语法错误,但是它在没有应用 where 子句的情况下给出了结果。例外输出:11 显示:48

但是选择查询工作正常,没有如下功能

select MAX(writenscore) as max from exam.marks WHERE Id = 1 and subject = 'maths';

我什至检查函数是否获得正确的参数。

标签: mysqlmysql-error-1064

解决方案


推荐阅读