DECLARE shopItemsCursor CURSOR FOR SELECT id, minItemId, maxItemId, price, amount FROM t_config_mine_shop WHERE appearType = 0; ...... FETCH shopItemsCursor INTO configId, minItemId, maxItemId, price, amount;
mysql版本是5.6.21,除了configId之外,其他字段都是null,但是数据库有值,查了下,发现需要给表加别名,并且字段前面带上表的别名,如下
DECLARE shopItemsCursor CURSOR FOR SELECT s.id, s.minItemId, s.maxItemId, s.price, s.amount FROM t_config_mine_shop s WHERE s.appearType = 0; ...... FETCH shopItemsCursor INTO configId, minItemId, maxItemId, price, amount;