On Dec 9, 11:06 am, Jay Mark <[EMAIL PROTECTED]> wrote: > I have to use subselect for this query. > find_all_by_name and joins will not work. > Please I need help with getting the correct syntax for doing subselect > the rails way. > The query works fine in mysql. > I can't find the syntax in the docs or may be I was looking in the wrong > place. > My project is due tomorrow. Please help!!! > Here is the query statement: > > @books = Books.find_by_sql ["SELECT * FROM books WHERE title IN SELECT > title FROM authors WHERE name = ?", params[:author][:name]] > > One problem is where to put the () that will enclose the inner select. > Or may be it is not needed. > > Thanks > Cypray. > -- > Posted viahttp://www.ruby-forum.com/.
I don't understand what tables and columns you've got here. Assuming you have a books table that has a title column, and an authors table with a name column, how do you relate books to authors? Is there a foreign key that relates the tables? Jeff --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

