Rails活动记录此sql的转换

时间:2012-08-24 21:12:40

标签: sql ruby-on-rails-3 activerecord

  

SELECT players.name,batsmen。* FROM batsmen INNER JOIN球员ON   players.id = batsmen.player_id WHERE league_id = 13

我将如何做到这一点?我正在使用Rails框架和MySQL。提前谢谢。

1 个答案:

答案 0 :(得分:3)

试试这个:

Player.joins(:batsmen).select('players.name, batsmen.*').where('batsmen.league_id = ?', 13)