如何在SQL中请求随机行?如何在纯SQL中请求随机行(或尽可能接近真正的随机行)?
4 回答
汪汪一只猫
TA贡献1898条经验 获得超8个赞
SELECT * FROM table ORDER BY RAND() LIMIT 1
SELECT * FROM table WHERE num_value >= RAND() * ( SELECT MAX (num_value ) FROM table ) ORDER BY num_value LIMIT 1
num_value
num_value
0..MAX(num_value)
12345678_0001
TA贡献1802条经验 获得超5个赞
ORDER BY NEWID()
7.4 milliseconds
WHERE num_value >= RAND() * (SELECT MAX(num_value) FROM table)
0.0065 milliseconds
!
添加回答
举报
0/150
提交
取消