就是不知道怎么添加多个 and 判断
select * from Issues where UserId='" + Session["Uid"].ToString() + "' and((Ztai='No')) order by id desc  //这个是OK的
想继续添加多几个and判断
select * from Issues where UserId='" + Session["Uid"].ToString() + "' and((Ztai='No')) and USDE='yes' and POL='yes' order by id desc//这个是NO的
select * from Issues wher a='1' and b='1' and c='1' and d='1' order by id desc应该怎么写?

解决方案 »

  1.   

    报什么错??
    UserId什么类型??
    Session["Uid"]存在不存在?select * from Issues where UserId='" + Session["Uid"].ToString() + "' and Ztai='No' and USDE='yes' and POL='yes' order by [id] desc 
      

  2.   

    select * from Issues where UserId=@UserId
    and((Ztai='No')) and USDE='yes' and POL='yes' order by id desc
    试试   @UserId下面装换成Session["Uid"].ToString() 就没有问题了,
    UserId='" + Session["Uid"].ToString() + "'代码不要这样写容易造成SQL注入
      

  3.   

    select * from Issues where a='1' and b='1' and c='1' and d='1' order by id desc 
      

  4.   

    select * from Issues where UserId='" + Session["Uid"].ToString() + "' and 这里少个空格((Ztai='No')) and USDE='yes' and POL='yes' order by id desc//这个是NO的 
      

  5.   

    select * from Issues wher a='1' and b='1' and c='1' and d='1' order by id desc 
      

  6.   

    分开绡sql语句判断写法 要在存储过程中来写的例
      declare @aa varchar
      select @aa=bb from cc where    // 获取数据 
      if @aa判断
          sql2
      else
         sql3