› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
raycloud
V2EX  ›  MySQL

在 MySQL 存储过程中,查询出来的结果集,不用游标还可以怎么遍历呢?

  •  
  •   raycloud · Oct 13, 2014 · 9231 views
    This topic created in 4369 days ago, the information mentioned may be changed or developed.
    现在是这样写的:
    DECLARE cur CURSOR FOR SELECT name FROM tb;
    OPEN cur;
    lbl1: LOOP
    FETCH cur INTO temp;
    IF done=1 THEN
    LEAVE lbl1;
    END IF;
    END LOOP;
    CLOSE cur;
    请问不用游标,直接循环结果集,怎么写呢?
    2 replies  •  2014-10-13 13:38:30 +08:00
    yrdr
        1
    yrdr  
       Oct 13, 2014
    简单的sql语句为何一定要扯上存储过程之类的呢?先不说麻烦,以后维护起来也折腾死人
    raycloud
        2
    raycloud  
    OP
       Oct 13, 2014
    @yrdr 用存储过程肯定不只是一个简单的查询,上面只是我遍历查询结果的一个例子
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5217 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:08 · PVG 11:08 · LAX 20:08 · JFK 23:08
    ♥ Do have faith in what you're doing.