Mysql 如何在RubyonRails中实现这个SQL查询

Mysql 如何在RubyonRails中实现这个SQL查询,mysql,sql,ruby-on-rails,activerecord,Mysql,Sql,Ruby On Rails,Activerecord,我这里有一个很好的SQL查询,我试图弄清楚如何使用rails的活动记录方法==> 选择 topics.id 来自主题 哪里 不存在 挑选* 投票 其中vows.topic_id=topics.id 试试这个 @topics = Topic.where("not exists (SELECT * FROM votes WHERE votes.topic_id = topics.id)")

我这里有一个很好的SQL查询,我试图弄清楚如何使用rails的活动记录方法==>

选择 topics.id 来自主题 哪里 不存在 挑选* 投票 其中vows.topic_id=topics.id 试试这个

@topics = Topic.where("not exists (SELECT * FROM votes WHERE votes.topic_id = topics.id)")