Hi there, assume that: 1 we have the following situation: Book :has_many Pages :has_many Illustrations ==== ===== ============ 2 certain pages have NO illustrations 3 the following 2 cases: A) Book.find(:all, :joins => [:pages => [:illustrations]]) B) Book.find(:all, :include => [:pages => [:illustrations]]) Question: Is it correct that: - in case A), the books containing pages WITHOUT any illustrations will NOT show up in the results - whereas in case B), these books WILL show up? (Personally, I thought that the main difference between :joins and :include was the "eager loading" part.) Thanks for any explanation for this! Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 2, 5:09 pm, Tom Ha <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Question: Is it correct that: > - in case A), the books containing pages WITHOUT any illustrations will > NOT show up in the results > - whereas in case B), these books WILL show up? > > (Personally, I thought that the main difference between :joins and > :include was the "eager loading" part.) >:joins does an inner join, :include doesn''t (and may not even do a join at all) Fred> Thanks for any explanation for this! > Tom > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> :joins does an inner join, :include doesn''t (and may not even do a > join at all)If you say "may not", when would it do or not do a join, then? And which type of join? Doesn''t :include amount to a LEFT JOIN, actually? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
IME :include does a join if you are using the ''included'' table in the query conditions: A.find(:all, :conditions => ''a.column=1'', :include => ''b'') # no join A.find(:all, :conditions => ''a.column=1 AND b.column=2'', :include => ''b'') # join On Jun 2, 3:14 pm, Tom Ha <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > :joins does an inner join, :include doesn''t (and may not even do a > > join at all) > > If you say "may not", when would it do or not do a join, then? And which > type of join? > > Doesn''t :include amount to a LEFT JOIN, actually? > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> A.find(:all, :conditions => ''a.column=1 AND b.column=2'', :include => > ''b'') # joinAnd if you say "join", you mean a "LEFT join" here, if I got the story right... Thanks, guys! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.