0
我想通过连接两个表来选择数量。 这是我的有效记录。通过这个我想从这些条件中选择'程序'表中的'金额'。请帮助如何通过连接两个表来选择列字段
Programme.joins(:subscriptions).where('programmes.coach_id=?',params[:id])
我想通过连接两个表来选择数量。 这是我的有效记录。通过这个我想从这些条件中选择'程序'表中的'金额'。请帮助如何通过连接两个表来选择列字段
Programme.joins(:subscriptions).where('programmes.coach_id=?',params[:id])
使用选择方法,并指定列,如: -
Programme.joins(:subscriptions).where('programmes.coach_id = ?', params[:id]).select("programmes.amount")
加入多个表: -
Programme.joins(:subscriptions, :students).where('programmes.coach_id = ?', params[:id]).select("programmes.amount")
在同一个表
如何加入学生表 – SreRoR