mysql - 插入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';
我什至检查函数是否获得正确的参数。
解决方案
推荐阅读
- opencv - 如何在 OpenCV 中获得与 ImageMagick 的“convert -fft”完全相同的结果?
- angular - 基于角色的角度路由到子路径
- microsoft-graph-api - MS Graph API 中的事件 ID 是唯一的吗?
- sql - 查询字符串为文本时 SQL 搜索失败
- c - 使用结构、指针和文本的学生数据库可避免出错
- apache-spark - numInputRows 在流中始终为 0 - Databricks Pyspark
- logging - Pentaho Data Integration 9 摆脱无用的日志行
- python - 迭代多维 Numpy 数组并除以
- laravel - 在自定义队列文件上设置 Laravel 队列优先级
- c++ - std::regex_match 引发堆栈溢出