做个随机抽题的网页,3类试题都保存在answer1数据表中,只是每类试题的type值不同,试了一下,使用一个条件查询没问题,
如:select top 10 * from answer1 where type=2 Order By Rnd(-id+"&Rnd()&")
但用下面的方法使查询结果集合一,但是执行起来好似进入死循环。
Randomize
sql = "select top 10 * from answer1 where type=2 Order By Rnd(-id+"&Rnd()&")
union select top 10 * from answer1 where type=1 Order By Rnd(-id+"&Rnd()&")
union select top 10 * from answer1 where type=0 Order By Rnd(-id+"&Rnd()&")"
到底是怎么回事呢?谢谢
------解决方案--------------------
order by newid() 不就可以了?