且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从mysql中的存储过程中检索多行?

更新时间:2022-03-26 22:19:11

该错误不在您的过程中.错误出在您的查询中-返回多于一行,但是您无法将多个结果设置为标量值'emp1'.

The error is not in your procedure. The error is in your query - it returns more then one row, but you cannot set multiple result into scalar value 'emp1'.

您应限制查询以使其返回一行.

You should limit your query so that it returns one row.

如何从mysql中的存储过程检索多行?

  • 计划A :填写另一个表格,它可能是临时表格.
  • 计划B :只需执行过程中没有INTO子句的SELECT语句即可;那么您可以从应用程序中读取数据集(c#,PHP + mysqli等)
  • 计划C :请勿使用该过程,只需执行SELECT查询即可.
  • Plan A: Fill another table, it may be a temporary table.
  • Plan B: Just execute your SELECT statement without INTO clause from the procedure; then you could read data-set from the application (c#, PHP+mysqli,...)
  • Plan C: Do not use the procedure, just execute the SELECT query.