MySQL Return

MySQL Return

MySQL Return syntax and example.
The RETURN statement terminates execution of a stored function and returns the value expr to the function caller.

Return example

CREATE FUNCTION return_value(x INT)
RETURNS TEXT
BEGIN
	IF x=1 THEN
		RETURN 'OK';
	ELSE
		RETURN 'NOK';
	END IF;
END;

SELECT return_value(1);

Output

FUNCTION RETURN_VALUE compiled
OK