mysql 定义function rand
时间:2021-07-01 10:21:17
帮助过:2人阅读
FUNCTION rand_num (
start_num INTEGER,
end_num INTEGER
) RETURNS INTEGER
BEGIN
RETURN FLOOR(start_num
+ RAND()
* (end_num
- start_num
+ 1));
END;
比如,要获取1-9的随机数,如此调用即可:
select rand_num(1, 9);
mysql 定义function rand
标签: