string strSql = "select count(1) from table where Status=1 and CompanyID=224";
object obj = DbHelperSQL.GetSingle(strSql, param);
if (obj == null)
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
上面运行起来就超时,条件改成其他CompanyID都正常。
后来把select count(1)改成select count(*)就都可以了
好像之前有一次也是这样,我把*改成1,现在又改回来了哈
这个是怎么回事,数据库的问题吗。怎么处理才能一劳永逸。
为什么要cout(1)呢? 如果你要只是想看id为224这条数据存不存在,那直接select 1 from 表 where 条件 就行了,存在就返回1 不存在就是null
count(1); 我不知道你要干什么