摘要: MySQL存储过程中的3种循环【转载】在MySQL存储过程的语句中有三个标准的循环方式:WHILE循环,LOOP循环以及REPEAT循环。还有一种非标准的循环方式:GOTO,不过这种循环方式最好别用,很容易引起程序的混乱,在这里就不错具体介绍了。这几个循环语句的格式如下: WHILE……DO……END WHILE REPEAT……UNTIL END REPEAT LOOP……END LOOP GOTO。 下面首先使用第一种循环编写一个例子。 mysql> create procedure pro10() -> begin -> declare i int; -> set 阅读全文
posted @ 2013-05-11 20:00 xki 阅读(202) 评论(0) 推荐(0) 编辑
摘要: static void Main(string[] args) { string sqlstr = "select * from manavatar"; MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString("192.168.0.13", "flashdata", "root", "root", 3306).AsString); DBConn.Open(); //MySQLDataAdapter myadap 阅读全文
posted @ 2013-05-11 18:30 xki 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 行号:Select UID,(@rowNum:=@rowNum+1) as rowNoFrom a,(Select (@rowNum :=0) ) b 阅读全文
posted @ 2013-05-11 18:29 xki 阅读(165) 评论(0) 推荐(0) 编辑
摘要: CREATE PROCEDURE `justifyGroupNum`() NOT DETERMINISTIC SQL SECURITY DEFINER COMMENT '' BEGIN /*how to run:call justifyGroupNum()*/ DECLARE p_group_id int; declare p_num int; declare stopFlag int; DECLARE cursor_name CURSOR FOR select c_group_id,count(*) as num from `t_group_member` where c_v 阅读全文
posted @ 2013-05-11 18:28 xki 阅读(210) 评论(0) 推荐(0) 编辑
摘要: --对一个表取任意随机数 SELECT * FROM TMP_XF_TEST WHERE ID >= (SELECT FLOOR(RAND() * (SELECT MAX(ID) FROM TMP_XF_TEST))) order by id LIMIT 1;--有条件性的取随机数 SELECT * FROM TMP_XF_TEST WHERE ID >= (SELECT FLOOR(RAND() * ((SELECT MAX(ID) FROM TMP_XF_TEST WHERE GID = 9) - (SELECT MIN(ID) FROM TMP_XF_TEST WHERE G 阅读全文
posted @ 2013-05-11 18:27 xki 阅读(148) 评论(0) 推荐(0) 编辑