Country- Company有一个1-n的关系.
Company- Dish有一段关系.
我需要根据各自区域设置中的计数从每个区域设置中获取Dishes,每个区域设置有100个结果.
到目前为止我有
SELECT dishes.title,
dishes.name,
dishes.id,
countries.locale
FROM countries
JOIN companies ON companies.`country_id` = countries.`id`
JOIN company_dish ON company_dish.`company_id` = companies.`id`
JOIN dishes ON company_dish.`dish_id` = dishes.`id`
GROUP BY dishes.`title`, countries.locale
ORDER BY ??? count_dishes_in_each_locale ?? DESC
Run Code Online (Sandbox Code Playgroud)
样本数据:
期望的输出:
我怎样才能做到这一点?