For example User_num table:
 
Example 1: a query that has occurred 2 times user
 
Often beginners mistakenly assume that the count () algorithm is used directly in the where statement, which is clearly wrong, and the count () method cannot be used in the WHERE clause, and to solve the problem, we can use the having to make conditional restrictions after the GROUP BY clause.
Error procedure: SELECT * from User_num where count (user) >=2 group by user;
Correct practice: SELECT * from User_num GROUP by user has count (user) >=2;
Explanation: Having is similar to where it can be used to determine which records to select. The HAVING clause is specified in the SELECT statement, showing which records are grouped by the GROUP BY clause. After group by combines records, having displays any records that are grouped by the GROUP BY clause that conform to the HAVING clause.
Example 2: querying a single user's num sum of more than 10 users
 
With the previous experience, the sum () method is written in the HAVING clause.
Correct practice: SELECT * from User_num GROUP by user has sum (num) >10;
NOTE: A HAVING clause can contain up to 40 expressions, and the expression of a HAVING clause may be split with and and OR.