mysql hvaing count
时间: 2023-07-23 15:38:46 浏览: 73
"HAVING COUNT" is a clause in MySQL used with the "GROUP BY" clause to filter the results of a query based on the count of a specific column.
For example, if you have a table of orders and you want to find the customers who have placed more than 5 orders, you can use the following query:
```
SELECT customer_id, COUNT(*) as num_orders
FROM orders
GROUP BY customer_id
HAVING num_orders > 5;
```
This will group the orders by customer_id and count the number of orders for each customer. The "HAVING" clause will then filter the results to only show the customers who have placed more than 5 orders.
阅读全文