Need help to represent the the logic in different way.There are 2 fields in opportunity Brokerage\_\_c which is a lookup to account and Broker\_Contact\_\_c which is lookup to contact.
There is a piece of code where a condition in if loop should be included in SOQL query itself.

Below is the code

```
thisQuery = 'Select Id, name FROM Opportunity WHERE isClosed = false AND AND RecordTypeId IN:recordTypeIds  ORDER BY CloseDate ASC Limit :queryLimit offset :queryOffset';
    oppListFromDb=Database.query(thisQuery);
    system.debug('******'+oppListFromDb.size());
    for(Opportunity o :Database.query(thisQuery)){
        if(o.Brokerage__c==o.Broker_Contact__r.AccountId){
        tempOppRecordIds.add(o.Id);
    }
 }

```

I have to represent the following if loop comparison in SOQL itself how can i do that?

Please guide me.

```
        if(o.Brokerage__c==o.Broker_Contact__r.AccountId)

```

Thanks.