Anyone knows how to do left join as well as inner join in same query


#1

Hello All,

Is rails supporting left and inner joins in same query ??
I dont wanted to do it using find_by_sql.

I have model having belongs_to and has_one associations.

I wanted to something like…

Model.find ( :all, left join on belongs_to model and inner join on
has_one
model, :select =>. “some attributes from all models” )

Thanks for help !

Sandip

Ruby on Rails Developer



www.joshsoftware.com


#2

On Wed, Jun 3, 2009 at 9:19 AM, Sandip R. removed_email_address@domain.invalid
wrote:

model, :select =>. “some attributes from all models” )

Thanks for help !

Sandip

Ruby on Rails Developer
http://sandip.sosblog.com
http://funonrails.wordpress.com
www.joshsoftware.com

Check the docs at
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002208

use :joins to include join SQL syntax
:joins => ‘inner join x outer join y’

Andrew T.
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings


#3

Thanks !

On Wed, Jun 3, 2009 at 12:57 PM, Andrew T. <
removed_email_address@domain.invalid> wrote:

http://funonrails.wordpress.com
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings


Ruby on Rails Developer
http://sandip.sosblog.com
http://funonrails.wordpress.com
www.joshsoftware.com