mysql tips - HAVING - another clause use to filter result like WHERE
Example: correct usage: SELECT c1, count(*) from t1 where Date like "2013-12-30 %" group by c1 HAVING count(*)>2 order by c1; wrong usage: SELECT c1, count(*) from t1 where Date like "2013-12-30 %" and count(*)>2 group by c1 order by c1; Because the aggregate function can not be used in WHERE clause. WHERE clause is used to SELECT the rows. And aggregate functions are after WHERE, and before HAVING. HAVING clause is used to filter the select result.