All pages
Powered by GitBook
1 of 1

Loading...

RETURN

Exit a stored function and return a value. This statement terminates function execution and sends the specified result back to the caller.

Syntax

RETURN expr

The RETURN statement terminates execution of a stored function and returns the value expr to the function caller. There must be at least one RETURN statement in a stored function. If the function has multiple exit points, all exit points must have a RETURN.

This statement is not used in , , or . can be used instead.

The following example shows that RETURN can return the result of a :

This page is licensed: GPLv2, originally from

CREATE FUNCTION users_count() RETURNS BOOL
   READS SQL DATA
BEGIN
   RETURN (SELECT COUNT(DISTINCT User) FROM mysql.user);
END;
stored procedures
triggers
events
LEAVE
scalar subquery
fill_help_tables.sql