RoR-Sql query

A

Anandh Kumar

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
 
R

Ryan Davis

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

please ask this on the rubyonrails list/forum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top