You can use the RETURN statement to end the execution of a stored function and return the result to the function invoker.
Syntax:
RETURN expr
A stored function must contain at least one RETURN statement. If a function has multiple exit points, it may contain multiple RETURN statements.
Stored procedures and triggers do not use the RETURN statement but use the LEAVE statement to exit a program.