使用IS NOT NULL忽略空为无效

时间:2014-06-10 10:58:58

标签: php mysql null

我有一个查询显示TyreMan列中最常见的值。此列中的很多值都是空的,所以我试图忽略它们,但它似乎没有工作。

$result = mysql_query("SELECT TyreMan, COUNT(TyreMan) AS countTyreMan 
                         FROM Pictures 
                        WHERE Tyreman IS NOT NULL 
                     GROUP BY TyreMan 
                     ORDER BY countTyreMan DESC 
                        LIMIT 1");

我把它放错了地方吗?

感谢

1 个答案:

答案 0 :(得分:0)

试试这个

      $result = mysql_query("SELECT TyreMan, COUNT(TyreMan) AS countTyreMan 
      FROM Pictures WHERE (Tyreman) IS NOT NULL 
      GROUP BY TyreMan ORDER BY countTyreMan DESC LIMIT 1");

使用()列名称。