Mode calculation without a subquery field in MySQL?
问题 In my application, each product group has many products, and each product has one manufacturer. These relations are stored by MySQL in InnoDB tables product_groups with an id field, and products with id , product_group and manufacturer fields. Is there a way to find the most common manufacturer in each product group, without resorting to selecting subqueries? This is how I'm doing it currently: SELECT product_groups.id, ( SELECT manufacturer FROM products WHERE product_group = product_groups