如何为Rails Active Record查询编写内连接

时间:2015-09-29 06:21:27

标签: ruby-on-rails activerecord

我希望Rails Active Record查询以防下面的SQL查询

感谢任何帮助

SELECT parent_id FROM categories INNER JOIN categories_coaches ON categories.id = categories_coaches.category_id

1 个答案:

答案 0 :(得分:1)

Category.select(:parent_id).joins(:category_coaches)