insert into YourTableName select top 5 qID from questions where categoryid=001 order by newid()唉,, 又来晚了。。
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
insert 另一表 select top 5 QID from questions where categoryid='001' order by newid()
select top 5 * from questions where categoryid=001 order by newid()
随机newid()排序 ====================================select top 5 * from questions where categoryid='001' order by newid()
select top 5 qID from questions where categoryid=001 order by newid()
select top 5 QID from questions
where categoryid='001'
order by newid()
select top 5 QID
from Questions
where Categoryid='001'
order by newid()
select top 5 QID
insert into #t
from questions
where categoryid='001'
order by newid()select * from #t
drop table #t
select top 5 QID
insert into #t
from questions
where categoryid='001'
order by newid()select * from #t
drop table #t
我可能会从不同的category里选questions。
假设:从001里选5题,002里选10题,003里选15题,
sql语句是怎样?如果你懂asp能否教我一下?我想把我要选的问题选出来后,生成一组试题。然后我每一页显示一题,怎样处理?
我还可以开贴给分。
select top 5 qID from questions where categoryid=001 order by newid()唉,,
又来晚了。。
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
select top 5 QID from questions
where categoryid='001'
order by newid()
====================================select top 5 * from questions where categoryid='001' order by newid()