简单问题一个。
组名 序号 姓名
1 1 xxx
1 2 xxx
1 3 xxx
1 4 xxx
.......
1 30 xxx
2 1 xxx
2 2 xxx
2 3 xxx
......
2 30 xxxx
要得到以上结果的表如何做?
1组30人,2组也是30人,都是这样,余下的放组后一组。
[解决办法]
try this,
SqlCommand myda=new SqlCommand("select a.考场,b.座号 from (select number '考场' from master.dbo.spt_values where type='P' and number between 1 and 2) a cross join (select number '座号' from master.dbo.spt_values where type='P' and number between 1 and 30) b", con);
myda.ExecuteNonQuery();
con.Close();
[解决办法]
是的,select仅是查询语句.
[解决办法]
两种方法:
1. cross join
2.select A.xx,B.xx
from A,B
[解决办法]
try this,
SqlDataAdapter myda = new SqlDataAdapter("select a.考场,b.座号 from (select 考场 from tb2 where 考场 between 1 and 2) a cross join (select 座号 from tb2 where 座号 between 1 and 30) b", con);
DataSet da = new DataSet();
myda.Fill(da);
GridView1.DataSource = da.Tables[0];
GridView1.DataBind();