Forum: Ruby on Rails Anyone knows how to do left join as well as inner join in same query.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4ab2692ba129cb296d4f2e90ba5241da?d=identicon&s=25 Sandip Ransing (san2821)
on 2009-06-03 09:21
(Received via mailing list)
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
http://sandip.sosblog.com
http://funonrails.wordpress.com
www.joshsoftware.com
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-06-03 09:38
(Received via mailing list)
On Wed, Jun 3, 2009 at 9:19 AM, Sandip Ransing <san2821@gmail.com>
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/Ba...

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

Andrew Timberlake
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings
4ab2692ba129cb296d4f2e90ba5241da?d=identicon&s=25 Sandip Ransing (san2821)
on 2009-06-03 11:38
(Received via mailing list)
Thanks !

On Wed, Jun 3, 2009 at 12:57 PM, Andrew Timberlake <
andrew@andrewtimberlake.com> 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
This topic is locked and can not be replied to.