Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MySQL - Random Number - Function
DROP FUNCTION IF EXISTS funcRandom;
delimiter //
CREATE FUNCTION funcRandom
(
low INT
, high int
)
RETURNS int
DETERMINISTIC
BEGIN
RETURN (
floor
(
rand() *
(
( high + 1 )
- ( low )
)
)
+ low
);
END;
//
delimiter ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.