若要在i ≤ R ≤ j 这个范围得到一个随机整数R ,需要用到表达式 FLOOR(i + RAND() * (j – i + 1))。
7 -20 区间整数,i=7 j=20 (j – i + 1)=14
最终 select FLOOR(7 + RAND() * 14) as rand
若要在i ≤ R ≤ j 这个范围得到一个随机整数R ,需要用到表达式 FLOOR(i + RAND() * (j – i + 1))。
7 -20 区间整数,i=7 j=20 (j – i + 1)=14
最终 select FLOOR(7 + RAND() * 14) as rand
下一篇:PHP 随机数字按权重
Mysql 随机查询目标可选查询方案MYSQL 的 RAND() 函数。自定义查询与排序条件(推荐)查询测试环境说明根据 MYSQL 的 RAND() 函数排序自定义查
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M