Reputation: 38
How to filter all the records from a table where a column 'name' is like (in any order) all the values from an array of strings
Upvotes: 1
Views: 1646
Reputation: 494
If you're using postgres DB please check the following answer since postgress has arrays.
You might want to do it at application level if your db is small.
If REGEXP is viable to you then the @khiav reoy answer is the best you could do.
Upvotes: 2
Reputation: 1403
You could use REGEXP
Model.where('name REGEXP ?', array_of_string.join('|'))
Upvotes: 3