How to Use delimiter// to solve MySQL end error

This is my initial error code:

1 create procedure search_sc (student_no varchar(6))
2     begin
3         select sc.* 
4         from sc
5         where sno= student_no
6     end;

Report the error: “Error Code: 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 ‘end’ at line 6


delimiter //
create procedure search_sc (student_no varchar(6))    
        select sc.* 
        from sc
        where sno= student_no;
    end //

It turns out that the MySQL interpreter is based on ‘;’ To end the read command and execute the command in multiple ‘;’ The interpreter does not know which sentence ends the read command and executes the command, and the function of the delimiter is to replace the flag after the delimiter with the flag after the delimiter (in this paper ‘/ /’), so that the MySQL interpreter will execute this sentence only after ‘/ /’ appears


Similar Posts: