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
Asked
Active
Viewed 1,494 times
2 Answers
3
You could use REGEXP
Model.where('name REGEXP ?', array_of_string.join('|'))

khiav reoy
- 1,373
- 13
- 14
2
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.

Community
- 1
- 1

Carlos J García
- 476
- 5
- 13