# Fwd: \[Rails\] is it possible for table intersection reference same table

**URL:** <https://www.ruby-forum.com/t/fwd-rails-is-it-possible-for-table-intersection-reference-same-table/144733>\
**Category:** Rails\
**Created:** [August 1, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/fwd-rails-is-it-possible-for-table-intersection-reference-same-table/144733 "2008-08-01T16:16:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tgreiser](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/258eb7/32.png) [@tgreiser](https://www.ruby-forum.com/u/tgreiser)\
**Post date:** [August 1, 2008, 4:16pm UTC](https://www.ruby-forum.com/t/fwd-rails-is-it-possible-for-table-intersection-reference-same-table/144733/1 "2008-08-01T16:16:35Z")

</div>

On Thu, Jul 31, 2008 at 7:42 PM, Beta B.  
\<removed\_email\_address@domain.invalid

> wrote:

> table\_mains = TableMain.find(:all,:include=\>[:table\_a, :table\_b,  
> :photo])
> 
> It only return left join from table\_b but not table\_a

try this:

table\_mains = TableMain.find(:all,  
:include=\> [:table\_a, :table\_b, :photo],  
:joins =\> “left join table\_a where table\_a.id =  
table\_mains.table\_a\_id  
left join table\_b where table\_b.id =  
table\_mains.table\_b\_id  
left join photo pa where pa.id =  
table\_mains.photo\_a\_id  
left join photo pb where pb.id =  
table\_mains.photo\_b\_id”)

–  
Tim G.
