SELECT .. INTO返回多个行-Mysql [英] SELECT .. INTO returns more than one rows - Mysql

查看:236
本文介绍了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?

我的目标是设置此结果

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆