我想在phpmyadmin中执行一个在表中插入行的循环。到目前为止,我有:
DELIMITER $$
DROP PROCEDURE IF EXISTS insert_my_rows()
CREATE PROCEDURE insert_my_rows()
BEGIN
DECLARE i INT DEFAULT 376;
WHILE i<405 DO
INSERT INTO wp_term_relationships(object_id,term_taxonomy_id,term_order) VALUES (i,16,0);
SET i=i+1;
END WHILE;
END $$
DELIMITER ;
CALL insert_my_rows()
有了这个,我得到一个错误:
#1064 - 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$$
DROP PROCEDURE IF EXISTS insert_my_rows()
CREATE PROCEDURE ins' at line 1
最佳答案
DROP PROCEDURE
语句的语法不正确!
更改
DROP PROCEDURE IF EXISTS insert_my_rows()
至
DROP PROCEDURE IF EXISTS insert_my_rows;
关于mysql - 如何在MySQL Shell中通过循环插入行(无PHP),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27074011/