Reputation: 27114
I'm trying to find objects that begin with a number.
Syntactically this is off. But I would like to do something like this :
Object.where([name LIKE ?', /[1-9]/])
If that isn't possible, how do you suppose the best way to find all objects that start with a number?
Upvotes: 2
Views: 438
Reputation: 16241
Select values that begin with a number
Object.where(['name REGEXP ?', '^[0-9]'])
Upvotes: 2
Reputation: 9093
You can use rlike / regexp i would think. Though it's not portable across to other databases.
http://dev.mysql.com/doc/refman/5.0/en/regexp.html#operator_regexp
Object.where(['name rlike ?', '^[\d]'])
Upvotes: 2