比如
c1    c2      c3       c4      c5
1     0       0        0       0 
0     1       0        0       0
0     0       1        0       0
0     0       0        0       0那么,检查结果应该为 
c1   c2    c3
1    0     0
0    1     0
0    0     1
0    0     0

直接得到c1,c2,c3的列名也行

解决方案 »

  1.   

    bool bFlag = false;
    CString str;
    for(int i = 0; i < 100; i ++){
    if(bColumn[i]){
    if(bFlag) str += ",字段i";
    else {
     str += "字段i";
     bFlag = true;
    }
    }
    }
    CString strSql;
    if(bFlag) strSql.Format("select %s from [table]", str);
      

  2.   

    select * from tbname
    遍历所有记录,所有列,对每一条记录的每一列进行判断
    参考http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=196279
    或者构造你的sql语句,像这样
    strSQL = "select * from tbname where c1 = 1";
    for (i = 1; i < 101; i++)
    {
       strFiledName.Format(" or c%d = 1", i);
       strSQL += strFieldName;
    }
    执行这个SQL(SQL可能太长了...)
      

  3.   

    看数据库支持了,SQL语句可以支持很长的.