选择"n".来自表2的"n"表示.从表1 [英] Select "n" Reords From Table2 "n" From Table1
本文介绍了选择"n".来自表2的"n"表示.从表1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表1
--- ----------------- ------- ---------
ID章理论问题
--- ----------------- ------- ---------
1 abc 5 3
2 xyz 4 2
3防御10 15
---------------------------------------
大家好
请救救我!!!!!!
我有两张桌子
表2包含数千个问题
我想从Table2中选择记录
使用表1
即我要从abc章中选择5个理论和3个问题随机问题,其中有1000个问题
从第Xyz章中选择4个理论和2个问题随机问题,其中有1000个问题
解决方案
从"abc"一章中选择5个理论问题
完成以下任务的任务说明
1.要进行联接,您的table1和table2应该至少有一个唯一的列,在您的情况下,它可能是章节"
2.在构建函数中使用 newid()来获取随机记录
//random 5 理论问题来自章节 abc' 选择 顶部 5 * 其中第= ' 订单 SQL联接 [Table 1 --- ----------------- ------- --------- ID Chapter Theory Problem --- ----------------- ------- --------- 1 abc 5 3 2 xyz 4 2 3 def 10 15 ---------------------------------------
Hello All Of You
Please Help Me!!!!
I has Two Tables
Table2 Contains Thousand Questions
I Want to select Records From Table2
Using Table 1
i.e. I Want Select 5 Theory And 3 Problems Random Question From Chapter abc Which Has 1000 Question
Select 4 Theory And 2 Problems Random Question From Chapter Xyz Which Has 1000 Question解决方案select 5 theory Question from chapter ''abc''
to achive task note following things
1. To make a join your table1 and table2 should have at least one unique column, in your case it may be ''chapter''
2. use newid() in build function to get random records
//random 5 theory Question from chapter 'abc' select Top 5 * from Table2 where Chapter ='abc' order by newid()
To do this, You have to select records using join from both tables. Following link will help you to write query
SQL Joins[^]
这篇关于选择"n".来自表2的"n"表示.从表1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文