Well, I don't know the answer, but you can probably use the sql query
mentioned in this page:
http://www.keithjbrown.co.uk/vworks/mysql/mysql_p5.php ( Do a browser search
on string "Joining Three Tables")

BTW, this email is to mention a different problem in your query: should not
card be cards and book be books in your query (table names are, by
convention, plural in rails) Try that too, might work.

Thanks,
Abhinav

--
अभिनव
http://twitter.com/abhinav



On Tue, Sep 8, 2009 at 10:55 AM, Anandh Kumar <
[email protected]> wrote:
>
>
>
> Hi everyone
>
> Consider there are three tables book,money,card in database.
>
> Book has got column names name,price.
>
> Money has got column names price,type.
>
> Card has got column names type,id.
>
> Now based on the 'id' of the 'card' i've to fetch 'name' of the 'book'.
>
> So i m writing a query in RoR model as
>
>
>
>          Book.find(:all, :select => "book.name",
>                 :joins => "INNER JOIN money ON money.price =
> book.price"+
>                 "INNER JOIN card ON card.type = money.type",
>                 :conditions => "`card`.`id` = '10'")
>
>
> But this doesnt work.Is there any alternate query or i m missing
> something in this query.
>
> Any help would be appreciated.
>
> Thanks in advance
>
> Anandh
> --
> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to