sql server:
select top 10 * from t_user order by newid() select * from (select * from t_user order by dbms_random.random()) where ronum <= 10 select * from t_user order by rand() limit 10access:
select top 10 * from t_user order by rnd([一个自动编号字段])这条语句在 access 中的“查询”中是可以运行并得到随机结果的,但在 asp.net等后台程序代码中却无法得到预期的随机效果。
正确的写法如下:
以asp.net为例:
random random = new random(system.guid.newguid().gethashcode());int r = random.next();
string sql = "select top 10 * from t_user order by rnd(" (-r) "*自动编号字段)"