问题
I am trying to retrieve multiple records from my DB with the following query:
User.where('name ilike ?','%thomas%')
this works fine. Now I want to retrieve multiple records at the same time and tried this (which seems to be syntactically incorrect):
User.where('name ilike any',['%thomas%','%james%','%martin%'])
What am I doing wrong?
So just to clarify: I want to retrieve all records that match one of the names, so its an OR statement I am looking for.
回答1:
You can do it by
User.where('name ilike any ( array[?] )',['%thomas%','%james%','%martin%'])
来源:https://stackoverflow.com/questions/26272082/postgresql-ilike-with-multiple-matches-in-rails-activerecord