# RoR-Sql query

**URL:** <https://www.ruby-forum.com/t/ror-sql-query/175064>\
**Category:** Ruby\
**Created:** [September 7, 2009, 8:51am UTC](https://www.ruby-forum.com/t/ror-sql-query/175064 "2009-09-07T08:51:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anandhkumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@anandhkumar](https://www.ruby-forum.com/u/anandhkumar)\
**Post date:** [September 7, 2009, 8:51am UTC](https://www.ruby-forum.com/t/ror-sql-query/175064/1 "2009-09-07T08:51:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anandhkumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@anandhkumar](https://www.ruby-forum.com/u/anandhkumar)\
**Post date:** [September 7, 2009, 9:35am UTC](https://www.ruby-forum.com/t/ror-sql-query/175064/2 "2009-09-07T09:35:58Z")

</div>

On Sep 6, 2009, at 23:54 , Anandh K. wrote:

> 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

please ask this on the rubyonrails list/forum.

---

<div class="post-metadata">

**Author:** ![anandhkumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@anandhkumar](https://www.ruby-forum.com/u/anandhkumar)\
**Post date:** [September 7, 2009, 1:47pm UTC](https://www.ruby-forum.com/t/ror-sql-query/175064/3 "2009-09-07T13:47:37Z")

</div>

Anandh

Why not use SQL - it’s so much better than this object-relational  
nonsense.
