SELECT .. INTO returns more than one rows - Mysql(SELECT .. INTO 返回多行 - Mysql)
问题描述
我有一个基本的存储过程
i have a basic stored procedure
DECLARE user_o VARCHAR(50);
SELECT user_name INTO user_o FROM users WHERE topic_id = 54 AND entry_time BETWEEN
2017-09-17 AND date_add( CURRENT_DATE, INTERVAL 1 DAY) ORDER BY entry_time ASC
LIMIT 10;
这会引发错误 #1172 sql 返回多行.不知道为什么?
this throws me error #1172 sql returns more than one rows. no idea why?
我的目标是得到这个结果集
my goal is to have this result set
user_name | user_o
mike mike
liz liz
helen helen
her her
推荐答案
这是因为您将结果INTO"插入到一个变量中,并且因为结果不止一个值,因此出现了错误.
Its because you are inserting the result 'INTO' a variable and because the result is more than a single value, hence the error.
您的限制为 10,尝试更改为 1,这将解决它,如果您想要返回多个值,那么您需要在记录集中管理这些值.
You have a limit of 10, try changing to 1, that will fix it, if you want multiple values returned then you need to manage these in a recordset.
这篇关于SELECT .. INTO 返回多行 - Mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SELECT .. INTO 返回多行 - Mysql
基础教程推荐
- 是否可以执行按位分组功能? 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
