How write between query in rails

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.

On Sep 2, 8:50 am, Sunny B. [email protected]
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.

: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 B. <

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs