I am trying something like this i want result which is between ? and ? with one condition but query gives me sql syntax exception. Group.find_by_sql(["select * from groups where lft BETWEEN (?) and (?) and in_directory=?",self.lft,self.rgt, 1]) how i solve it. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 2, 8:50 am, Sunny Bogawat <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I am trying something like this i want result which is between ? and ? > with one condition but query gives me sql syntax exception.You don''t need the () with between. Fred PS find_by_sql is unnecessary here.> > Group.find_by_sql(["select * from groups where lft BETWEEN (?) and (?) > and in_directory=?",self.lft,self.rgt, 1]) > > how i solve it. > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
:o group = Group.find(:all,:conditions => [''lft BETWEEN ? and ? and in_directory= ? '',self.lft,self.right,1]) hope this might be ur looking On Tue, Sep 2, 2008 at 1:20 PM, Sunny Bogawat < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I am trying something like this i want result which is between ? and ? > with one condition but query gives me sql syntax exception. > > Group.find_by_sql(["select * from groups where lft BETWEEN (?) and (?) > and in_directory=?",self.lft,self.rgt, 1]) > > how i solve it. > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---