MySQL throws error 1308 when a LEAVE or ITERATE statement references a loop label that does not exist in the current scope of a stored routine.
MySQL Error 1308: ER_SP_LILABEL_MISMATCH occurs when a LEAVE or ITERATE points to a non-existent loop label in a stored procedure. Match or add the correct label to resolve the compile-time failure.
%s with no matching label: %s
The message "%s with no matching label: %s" appears when the MySQL parser compiles a stored program and finds a LEAVE or ITERATE statement whose label does not correspond to any enclosing LOOP, REPEAT, WHILE, or BEGIN…END block. The compile halts and error 1308 is returned.
The error is raised at definition time, so your procedure or trigger is not created or altered until the mismatch is resolved.
Fixing the label alignment allows the stored routine to compile and run correctly.
MySQL requires every ITERATE or LEAVE to reference a label defined on an outer control-flow structure.
Using a misspelled label, omitting the label on the loop, or placing the jump statement outside the loop scope causes a mismatch and triggers error 1308.
Copy-pasting code between procedures, refactoring loop names, or auto-formatting can silently break label consistency and introduce this compile-time failure.
Verify that each LEAVE and ITERATE statement names a label that is defined on an enclosing loop.
Correct typographical errors, add missing labels, or move the jump statement inside the proper loop scope.
Recreate or alter the procedure after the correction.
Running SHOW WARNINGS immediately after CREATE PROCEDURE pinpoints the problematic line number, speeding up debugging.
Unlabeled LOOP with labeled LEAVE: add a label before the LOOP keyword or remove the label from LEAVE.
Misspelled label: rename either the loop label or the LEAVE/ITERATE reference so they match exactly, including case if lower_case_table_names is 0.
Nested loops: ensure the jump targets the intended outer or inner loop by matching the correct label.
Adopt a consistent naming convention for loop labels, such as prefixing with loop_ and numbering nested structures.
This reduces typos and mismatches.
Use Galaxy’s SQL editor linting to highlight unmatched labels in real time, preventing the error before you run CREATE PROCEDURE.
Error 1307 (ER_SP_LABEL_MISMATCH) occurs when LEAVE/ITERATE label conflicts with a handler label. Resolve by using distinct names for handlers and loops.
Error 1305 (ER_SP_DOES_NOT_EXIST) surfaces when calling a routine that was never created, often after error 1308 blocked compilation. Recreate the routine once label mismatches are fixed.
.
It is a compile-time error. The stored program will not be created or altered until the label mismatch is fixed.
Yes when lower_case_table_names is 0 on Unix-like systems. Maintain exact case to avoid mismatches.
Galaxy’s real-time linting flags unmatched LEAVE/ITERATE labels while you type, letting you correct mistakes before executing CREATE PROCEDURE.
You may omit the label only if you have a single loop in the current scope. Multiple loops require explicit labels to direct the jump.