如何通过连接两个表来 select 列字段
How to select a column field by joining two tables
我想通过加入两个 table 来 select 数量。
这是我的活跃记录。通过这个,我想在这些条件下从 'programme' table select 'amount'。请帮助
Programme.joins(:subscriptions).where('programmes.coach_id=?',params[:id])
使用 select 方法并指定列,如:-
Programme.joins(:subscriptions).where('programmes.coach_id = ?', params[:id]).select("programmes.amount")
加入多个 table 作为:-
Programme.joins(:subscriptions, :students).where('programmes.coach_id = ?', params[:id]).select("programmes.amount")
我想通过加入两个 table 来 select 数量。 这是我的活跃记录。通过这个,我想在这些条件下从 'programme' table select 'amount'。请帮助
Programme.joins(:subscriptions).where('programmes.coach_id=?',params[:id])
使用 select 方法并指定列,如:-
Programme.joins(:subscriptions).where('programmes.coach_id = ?', params[:id]).select("programmes.amount")
加入多个 table 作为:-
Programme.joins(:subscriptions, :students).where('programmes.coach_id = ?', params[:id]).select("programmes.amount")