How can I translate this MySQL's WHERE to ActiveRecord :condition?
SELECT * FROM users WHERE LENGTH(users.last_name) < 3
Thanks!
How can I translate this MySQL's WHERE to ActiveRecord :condition?
SELECT * FROM users WHERE LENGTH(users.last_name) < 3
Thanks!
User.find(:all, :conditions => ["LENGTH(last_name) < ?", 3])
or you can use find_by_sql
User.find_by_sql("SELECT * FROM users WHERE LENGTH(users.last_name) < 3")