Filter by a relation column

I’m an Android developer working with
Assuming there are two classes. Class1 and Class2.
Class1 has a relation column to Class2.
I need to query Class1 and find the rows which their relation column, contains a specific Class2 object. The specific Class2 object is available.
I think that one way is to fetch all rows of Class1, and check if the relation column contains that specific Class2 object for each row. But I believe it is the worst-practice possible :slight_smile:
So is there any other way to achieve this in android?

Something like this should work:

ParseQuery<ParseObject> query = ParseQuery.getQuery("Class1");
query.whereEqualTo("theNameOfTheRelationColumn", theClass2Object);

You can see more details about Many-To-Many relations here.