How to loop through a table using a cursor in MySQL?

隐身守侯 提交于 2019-12-03 21:09:35

The PROCEDURE above return only one row, because you update your variables(vDate, vInQty, tOutQty) every time inside the REPEAT body.

My suggestion to fix that is:

  1. CREATE TEMPORARY TABLE tmp_table, which each variable represent a column in this tmp_table.
  2. inside the REPEAT insert into that tmp_table.
  3. select * from temp_table.
  4. DROP tmp_table. /* Clean up */
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!