📜  联接和分组以及大小以使查询返回散列 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:17.532000             🧑  作者: Mango

代码示例1
Tagging.joins(:tag).group(:name).size
   (0.4ms)  SELECT COUNT(*) AS count_all, `name` AS name FROM `taggings` INNER JOIN `tags` ON `tags`.`id` = `taggings`.`tag_id` GROUP BY `name`
 => {"applesauce"=>1, "oranges"=>2}