mysql>delimiter//mysql>CREATEPROCEDUREp14()->BEGIN->DECLARElineINT;->SETline=0;->WHILEline<73059DO->deletefromtest1wherecheck_out_id=(selectidfromidorderbyidlimit`line`,1...
mysql> delimiter //
mysql> CREATE PROCEDURE p14()
-> BEGIN
-> DECLARE line INT;
-> SET line=0;
-> WHILE line<73059 DO
-> delete from test1 where check_out_id=(select id from id order by id limit `line`,1);
-> SET line=line+1;
-> END WHILE;
-> END //
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`line`,1);
SET line=line+1;
END WHILE;
END' at line 6
mysql> drop procedure if exists p14;
-> delimiter //
Query OK, 0 rows affected, 1 warning (0.00 sec)
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delimiter' at line 1
mysql> CREATE PROCEDURE p14()
-> BEGIN
-> DECLARE line INT;
-> SET line=0;
-> WHILE line<73059 DO
-> insert into id values(line);
-> SET line=line+1;
-> END WHILE;
-> END //
Query OK, 0 rows affected (0.00 sec)
为什么这个sql语句会报错,line换成数字可以在mysql中执行的
展开