MSSQL 有一表A 字段 id, temName, temId, tempContents 其中temName为模板名,现要求根据要求能不能取得数据按temName排序,取得con_no1 5000条后再取 con_no2 5000条 以次取下去。。只到完为止,不足5000就取模板实际数。
con_no1 120000条
con_no2 110000条
con_no3 5000条
con_no4 70000条
con_no5 5000条
con_no6 20000条
con_no7 100000条
con_no8 200000条
con_no9 100000条
con_no10 2000条
con_no11 2000条
con_no12 6000条
共10万数据
con_no1 120000条
con_no2 110000条
con_no3 5000条
con_no4 70000条
con_no5 5000条
con_no6 20000条
con_no7 100000条
con_no8 200000条
con_no9 100000条
con_no10 2000条
con_no11 2000条
con_no12 6000条
共10万数据
select top 5000 * from A where temName ='con_no2' union all
select top 5000 * from A where temName ='con_no3' union all
.....
select top 5000 * from A where temName ='con_no11' union all
select top 5000 * from A where temName ='con_no12'
楼主三的方法。。太复杂了。。数量大的话。写SQL会写死的。而且模板也比较多35个。目前。。这样要写多少次?