title: How to perform equal-to comparison on multiple columns in Realm
body: <p>I'm trying to create a method for querying a table in Realm with the option for excluding certain rows (by their IDs). Since Realm doesn't support multiple equal parameters similar to its <code>findAllSorted(String[], boolean[])</code> method, I'm performing it in a loop.</p>
  
  <p>Is there a better way to do this job?</p>
  
  <pre><code>public static RealmResults&lt;MessageItem&gt; getAll(long threadId, Collection&lt;Long&gt; excludedMessageIds) {
  
          final Realm realm = Realm.getDefaultInstance();
          RealmQuery&lt;MessageItem&gt; allMessagesQuery = realm.where(MessageItem.class);
  
          // Apply conditions
          // 1. Thread to look into
          if (threadId != -1)
              allMessagesQuery = allMessagesQuery.equalTo(MessageItem.COLUMN_THREAD_ID, threadId);
  
          // 2. Message IDs to exclude
          for (final Long excludedMessageId : excludedMessageIds) {
  
              allMessagesQuery = allMessagesQuery.notEqualTo(
                      MessageItem.COLUMN_MESSAGE_ID,
                      excludedMessageId
              );
  
          }
  
          return allMessagesQuery.findAll();
  
      }
  </code></pre>