Skip to main content
1 of 2
developer__c
  • 1.3k
  • 1
  • 15
  • 36

SOQL Where Object.Field != RelatedObject.Field

Is it possible, to have a self-referencing where clause in a SOQL query?

For example, I am trying to find where Account and Opportunity currency codes do not match, and I thought something like the following would work?

SELECT Id, CurrencyIsoCode, Account.Name, Account.CurrencyIsoCode FROM Opportunity WHERE Account.CurrencyIsoCode != CurrencyIsoCode

However, when I try and execute this I get an Unknown Error Parsing Query message.

Is what I am trying to do possible? I have reviewed the whole Force.com SOQL and SOSL Reference guide and cannot see anything suggesting how to do this.

developer__c
  • 1.3k
  • 1
  • 15
  • 36