V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
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 · 8897 views
    This topic created in 4215 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   ·   Solana   ·   2575 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 16:08 · PVG 00:08 · LAX 09:08 · JFK 12:08
    ♥ Do have faith in what you're doing.