Rails: Using greater than/less than with a where statement

Adam Templeton picture Adam Templeton · Jul 3, 2012 · Viewed 119.8k times · Source

I'm trying to find all Users with an id greater than 200, but I'm having some trouble with the specific syntax.

User.where(:id > 200) 

and

User.where("? > 200", :id) 

have both failed.

Any suggestions?

Answer

RadBrad picture RadBrad · Jul 3, 2012

Try this

User.where("id > ?", 200)