duanbi8529 2015-10-20 07:01
浏览 127

调用返回多行的mysql存储过程时出错

I want write a stored procedure that return more than one row.

My stored procedure is (it is only an example)

DELIMITER $$

CREATE PROCEDURE get_users(out get_users varchar(30))
BEGIN
    select name into get_users from tbl_join;

END

Now I want to call the stored procedure and display result in phpmyadmin.

call get_users(@out);
select @out;

Then an error occured.

#1172 - Result consisted of more than one row

My table tbl_join is:

id    name      date

1     Anil     2000-09-12
2     Rahul    2001-02-04
3     Lijin    1999-12-21

Expected result is:

Anil
Rahul
Lijin

Simply I want a Stored Procedure for the above result. Please help me..

  • 写回答

1条回答 默认 最新

  • duangaoe9401 2015-10-20 07:31
    关注

    A query like this

    select name into get_users from tbl_join;
    

    is kind of pointless. In a relational database there is no order unless you specify it. In theory you could get another random row each time you execute this query. Write it like this

    select name into get_users from tbl_join order by name limit 1;
    

    to get the first name in alphabetical order, for example.

    评论

报告相同问题?

悬赏问题

  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错