这条sql语句写的对吗?执行起来似乎进入死循环一样
本帖最后由 ztt918zx 于 2013-05-18 22:14:23 编辑
做个随机抽题的网页,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() 不就可以了?