`

rails find方法

阅读更多
User.find(
:all,  
:select => "name.*",
:from => "users",
:joins => " inner join role_relations rr on rr.user_group_id = ugn.user_group_id ",
:conditions => "rr.user_id = #{user_id} and ugn.news_id = #{news_id}")

解释成sql语句 select  name.* from users inner join role_relations rr on rr.user_group_id = ugn.user_group_id where rr.user_id = #{user_id} and ugn.news_id = #{news_id}"
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics