HAVING in mysql PHP
We can not use where keyword with aggregate functions That's why the MySQL HAVING clause uses with aggregate functions. The MySQL HAVING clause is often used with the GROUP BY clause.
For example :
Wrong Query :
$query = 'select count(order_id),customer_id from sales_order group by customer_id where count(order_id) > 10';
Right Query :
$query = 'select count(order_id),customer_id from sales_order group by customer_id HAVING count(order_id) > 10';
No comments:
Post a Comment