On 10 Dec 2008, at 06:55, Priya Dharsini wrote:
> > @books = Book.find(:all, :joins=>"books inner join authors as a on > books.title=a.name", :conditions => ['name LIKE ? ', > '%'+params[:author][:name]+'%']) What out for sql injection there. Fred > > > > try with the above code > > Jay Mark 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 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 -~----------~----~----~----~------~----~------~--~---

