add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
-- create stored procedure (once)

CREATE PROCEDURE execute_many_queries (queries_text TEXT)
BEGIN
REPEAT
SET @sql := SUBSTRING_INDEX(queries_text, ';', 1);
SET queries_text := TRIM(LEADING ';' FROM TRIM(LEADING @sql FROM queries_text));
PREPARE stmt FROM @sql;
EXECUTE stmt;
DROP PREPARE stmt;
UNTIL queries_text = '' END REPEAT;
END
-- create testing table

CREATE TABLE test (id INT, val INT);
-- execute 3 queries by 1 statement

CALL execute_many_queries ('INSERT INTO test VALUES (1,11), (2,22); UPDATE test SET val = 222 WHERE id = 2; SELECT * FROM test;');
id val
1 11
2 222
-- execute more 2 queries by 1 statement

CALL execute_many_queries ('UPDATE test SET val = 111 WHERE id = 1; SELECT * FROM test;');
id val
1 111
2 222