When I run the following query in query editor I get this error.
Error
Unknown error parsing query
Query
SELECT Id, OwnerId,Account.OwnerId
FROM Contact where OwnerId = Account.OwnerId limit 100
Does anybody know what the problem is?
When I run the following query in query editor I get this error.
Error
Unknown error parsing query
Query
SELECT Id, OwnerId,Account.OwnerId
FROM Contact where OwnerId = Account.OwnerId limit 100
Does anybody know what the problem is?
Best Answer
You can't compare a field to another field in
SOQL
.Salesforce has added a clear Knowledge Article to make that clear. From Field to field comparison in an SOQL WHERE clause:
Originally I also pointed to the documentation on fieldExpression Syntax (emphasis mine):
A common workaround is to create a checkbox formula to the same effect. Then just check if it's true in your query.