Reputation: 946
I have an AREL query:
@group.members.where('member_id != ?', 4)
As expected, this query returns all members with an ID not equal to 4.
How would I build the same type of query to omit multiple IDs? For example:
@group.members.where('member_id != ?', [4 3])
Which would ideally return all members with an ID not equal to either 4 or 3.
Upvotes: 3
Views: 2222
Reputation: 54882
The correct syntax is:
@group.members.where('member_id NOT IN (?)', [4, 3] )
This also work if you pass only one integer (not an array):
@group.members.where('member_id NOT IN (?)', 12)
Upvotes: 3