You have a mistake in the code, if you only need the result, you will get it from a simple choice to assign the word INTO , like this, remember that it returns the last.
CREATE FUNCTION test (i CHAR) RETURNS VARCHAR(SIZE) NOT DETERMINISTIC BEGIN DECLARE select_var VARCHAR(SIZE); SELECT name INTO select_var FROM table WHERE id = i; RETURN select_var; END$$
source share