string sql = "select * from userlist where username = '" + this.txtname.Text + "' and ppassword = '" + this.txtpwd.Text + "' and usertype = '"+this.ddlsubschoolname.Text+"'";string sss = "  select sum(cast(c.ischeck  as   tinyint))as summ ,count (*) as countt    from roleright a inner join RoleRight b ON A.Funname = '工作安排' AND b.FunListType = A.FunId  inner join usertypefun c on c.funid = a.funid and c.usertype = '" + Session["branch"].ToString()+"'";其中Session["branch"].ToString()是前一个查询语句中的usertype
怎么把这两条语句变为一条语句。

解决方案 »

  1.   

    string sss = "  select sum(cast(c.ischeck  as   tinyint))as summ ,count (*) as countt    from roleright a inner join RoleRight b ON A.Funname = '工作安排' AND b.FunListType = A.FunId  inner join usertypefun c on c.funid = a.funid and c.usertype = '"+this.ddlsubschoolname.Text+"'";
      

  2.   

    我是想只查询一次把要查询的都查出来,可能方法有点笨,sql也没学好。
    select * from userlist where username = 'dan' and ppassword = 'dan' and usertype = 1 select sum(cast(c.ischeck  as   tinyint))as summ ,count (*) as countt   
     from roleright a inner join RoleRight b ON A.Funname = '工作安排' 
    AND b.FunListType = A.FunId  inner join usertypefun c on c.funid = a.funid and c.usertype = 1
      

  3.   

    select * from userlist where username = 'dan' and ppassword = 'dan' and usertype = 1 union allselect  '','',''...补上*-2个列sum(cast(c.ischeck  as   tinyint))as summ ,count (*) as countt   
     from roleright a inner join RoleRight b ON A.Funname = '工作安排' 
    AND b.FunListType = A.FunId  inner join usertypefun c on c.funid = a.funid and c.usertype = 1
    --------------------
    因表结构不清楚,只能这样理解了~~