select top 5 * from questions where categoryid=001 order by newid()

解决方案 »

  1.   

    怎样把值返回到另一张表中(仅返回QID)
      

  2.   

    insert into tab(id)
    select top 5 qID from questions where categoryid=001 order by newid()
      

  3.   

    insert 另一表 
    select top 5 QID from questions 
    where categoryid='001' 
    order by newid()
      

  4.   

    随机选择,要加newid()做排序select top 5 * from questions where categoryid='001' order by newid()
      

  5.   

    insert TableName (ID)
    select top 5 QID 
    from Questions 
    where Categoryid='001' 
    order by newid()
      

  6.   

    select top 5 * from questions where categoryid=001 order by newid()
      

  7.   

    insert 另一表 
    select top 5 QID
    insert into #t
    from questions 
    where categoryid='001' 
    order by newid()select * from #t
    drop table #t
      

  8.   

    多了一行
    select top 5 QID
    insert into #t
    from questions 
    where categoryid='001' 
    order by newid()select * from #t
    drop table #t
      

  9.   

    select top 5 questions from questions where category='001' order by newid()值返回就用 select into 
      

  10.   

    谢谢楼上各位,还有个问题就是我是在写一个在线考试系统(用asp)。
    我可能会从不同的category里选questions。
    假设:从001里选5题,002里选10题,003里选15题,
    sql语句是怎样?如果你懂asp能否教我一下?我想把我要选的问题选出来后,生成一组试题。然后我每一页显示一题,怎样处理?
    我还可以开贴给分。
      

  11.   

    insert into YourTableName
    select top 5 qID from questions where categoryid=001 order by newid()唉,,
    又来晚了。。
      

  12.   

    insert TableName (ID)
    select * from ( select top 5 QID 
                    from Questions 
                    where Categoryid='001' 
                    order by newid()
                  ) a
    union all
    select * from ( select top 10 QID 
                    from Questions 
                    where Categoryid='002' 
                    order by newid()
                  ) b
    union all
    select * from ( select top 15 QID 
                    from Questions 
                    where Categoryid='003' 
                    order by newid()
                  ) c
      

  13.   

    insert 另一表 
    select top 5 QID from questions 
    where categoryid='001' 
    order by newid()
      

  14.   

    select top 5 * from questions where categoryid=001 order by newid()
      

  15.   

    随机newid()排序
    ====================================select top 5 * from questions where categoryid='001' order by newid()