mysql - Convert Inner Join to Left Join in rails -
i have rake file , , have code on . .
if circle[:conference2_total_channels].present? conf = confbridge.find(:all, :conditions => ["confbridges.cid = ?",circle.circle_number], :joins => [:confbridge_participants], :select => 'confbridges.id, confbridges.confno, confbridges.max_member, (confbridges.max_member - 5) additional , (confbridges.max_member - ifnull(confbridge_participants.active,0)) vacant') end
the return of code
select confbridges.id, confbridges.confno, confbridges.max_member, (confbridges.max_member - 5) additional , (confbridges.max_member - ifnull(confbridge_participants.active,0)) vacant `confbridges` **inner join** `confbridge_participants` on `confbridge_participants`.`confbridge_id` = `confbridges`.`id` (confbridges.cid = '0090000092')
it inner join
how can change left join
like
select confbridges.id, confbridges.confno, confbridges.max_member, (confbridges.max_member - 5) additional , (confbridges.max_member - ifnull(confbridge_participants.active,0)) vacant `confbridges` **left join** `confbridge_participants` on `confbridge_participants`.`confbridge_id` = `confbridges`.`id` (confbridges.cid = '0090000092')
thanks :)
this how write it:
confbridge.where("confbridges.cid = ?",circle.circle_number) .joins("left join confbridge_participants on confbridge_participants.confbridge_id = confbridges.id") .select(...your select statement)
Comments
Post a Comment