$vote=mysql_fetch_array(mysql_query("select sum(vcount) as vcount from votecount where titleid='$data[id]' "));=>
$id = $data['id'];
$vote=mysql_fetch_array(mysql_query("select sum(vcount) as vcount from votecount where titleid='$id' "));

解决方案 »

  1.   

    貌似sum(vcount),id的数量不等吧。
      

  2.   

    貌似sum(vcount),id的数量不等吧。
      

  3.   

    $sql="select sum(vcount) as vcount from votecount where titleid=".$data[id];
    $vote=mysql_fetch_array(mysql_query($sql)); 
    注意变量在单引号,有可能不会被解析
      

  4.   

    你mysqlquery后如果检查mysql_error就能看到出错信息:Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
    如果非要出结果,可以加上 group by null但是这里的id是不确定的,你的id想得到哪个行的值?
    这样查询出来,会根据实际存储顺序出现不同的id,无法控制
      

  5.   

    ("select sum(vcount) as vcount,id from votecount where titleid='$data[id]' ")); 
    echo SQL看一下就知道了再mysql_error()看一下
      

  6.   

    我想得到符合titleid='$data[id]'条件的各行的id和各行vcount的和,不知道这样子查询可不可以?
      

  7.   

    一般错误,改成$vote=mysql_fetch_array(mysql_query("select sum(vcount) as vcount,max(id) from votecount where titleid='$data[id]' ")); 
    $votenum=$vote[vcount]; 看看如果按上面修改的话,要求你的ID必须不是唯一的,不能是自增之类的字段.
      

  8.   

    我想得到符合titleid='$data[id]'条件的各行的id和各行vcount的和,不知道这样子查询可不可以?------------------------------------------------------------------------------“各行”和“各行”的vcount的和
    无法同时得到,这种纯sql问题,在mysql里多测试就行了,也容易发现问题