Skip to main content
added 32 characters in body
Source Link
cropredy
  • 73.3k
  • 8
  • 128
  • 283

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.

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.

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.

Source Link
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.