摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
行号:Select UID,(@rowNum:=@rowNum+1) as rowNoFrom a,(Select (@rowNum :=0) ) b 阅读全文
摘要:
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 阅读全文
摘要:
--对一个表取任意随机数 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 阅读全文