is it possible for table intersection reference same table

Hi,

Hopefully this is not confusing. ---- WHAT I need is this below ---------------- SQL Statement Select * from table_mains 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

try this:

table_mains = TableMain.find(:all,

:include=> [:table_a, :table_b, :photo],

   :joins => "left join table_a where [table_a.id](http://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")

Just in case, if any one else interested.

I resolved the problem by using class_name in has_many