Skip to content

Instantly share code, notes, and snippets.

@rdsilver
Last active August 29, 2015 13:56
Show Gist options
  • Save rdsilver/9060283 to your computer and use it in GitHub Desktop.
Save rdsilver/9060283 to your computer and use it in GitHub Desktop.
I want to be able to call this function with something like "SELECT test() FROM tableName"
I'm getting an error on line 8 when I try to make the function
DELIMITER $$
CREATE FUNCTION test()
RETURNS TEXT
BEGIN
DECLARE max_id INT;
SET max_id = SELECT max(id); //Erroring
RETURN CONCAT('Max ID is', max_id, ' !');
END;
$$
DELIMITER ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment