你的结果集不为空,当然>0啦.不过你上面的sql语句好像有错吧?mysql的函数要单独用,只能是
select count(*) from city left join othertable on othertable.cityid=city.cityid 
where othertable.cityid=city.cityid 
group by cityid
执行上面的语句如果你的结果集为空就会返回0.

解决方案 »

  1.   

    select city.cityid,city.city,count(othertable.cityid) from city 
    left join othertable on othertable.cityid=city.cityid 
    where othertable.cityid=city.cityid 
    group by cityid
      

  2.   

    hy2003fly()这样也不行呀
    我的意思是:
    city表里是记录的是全省的所有城市名,othertable表里存的是违法案件(不一定每个城市里都有违法案件),我想统计全省所有城市里的违法案件数量,没有的返回0,两个表之间是用cityid关连的
    我想得到类似如下的结果:
    城市名  案件数量
    东营    10
    菏泽    15
    济南    0
    ...........
      

  3.   

    你的表结构是不是这样?
     city                |   othertable
     cityid    cityname  |   案件id   案件名  cityid 
    如果是的话,你这样不就行了
    mysql>select count(案件id) from city,othertable where city.cityid=othertable.cityid;
    这样,一条一条输,很麻烦的哦.
      

  4.   

    select city.cityname, count(othertable.cityid) as number from city left join othertable on city.cityid = othertable.cityid group by city.cityname;
      

  5.   

    rardge(Rardge)像您这样不可以,有好多重复的数据
      

  6.   

    hy2003fly() 结构基本上跟你描述的差不多,但没有一个Sql语句就能实现我那问题的吗?