select top 6 Voter from tblVOTEVoteRecord a left join
tblVOTEActivityInfo b on a.ActivityID=b.ActivityID
where a.ActivityID='43bf7430dbae435ca0c1f4856eb8cefa' order by newid()查询出来的结果如下:
Voter
1111
2222
3333
4444
5555
6666我该如何把查询到的这些值插入到另一个表中,循环遍历这个查询的结果,但是该如何写,求大虾门指点下,我新手。
tblVOTEActivityInfo b on a.ActivityID=b.ActivityID
where a.ActivityID='43bf7430dbae435ca0c1f4856eb8cefa' order by newid()查询出来的结果如下:
Voter
1111
2222
3333
4444
5555
6666我该如何把查询到的这些值插入到另一个表中,循环遍历这个查询的结果,但是该如何写,求大虾门指点下,我新手。
2.从临时表插入正式表
3.再遍历临时表
select top 6 Voter into #temp from tblVOTEVoteRecord a left join
tblVOTEActivityInfo b on a.ActivityID=b.ActivityID
where a.ActivityID='43bf7430dbae435ca0c1f4856eb8cefa' order by newid()insert yourtable select * from #tempselect * from #temp
DataTable dt = DrawingRules.GetPhoneNumber(n, activityID);
for (int t = 1; t <= dt.Rows.Count; t++)
{
string phoneNumber = dt.Rows[t][0].ToString();
bResult = DrawingRules.InsertWinnerList(Common.NewGuid, this.DrawingID, activityID, id.Text, phoneNumber);
}
就是这样的,但是我这个有错,
改成 for (int t = 1; t < dt.Rows.Count; t++)2、如果还错的话,就要看DrawingRules.InsertWinnerList()这个方法的问题了。
count=9的时候索引是0--8