You need to sign in to do that
Don't have an account?
Victor Bogolyubov
Very strange (at least for me) SOQL parsing error
Hello,
I got Unknown error parsing query error. Can somebody explain what is going on, please? Thank you.
1. This is OK
SELECT Contact__r.Id, Contact__r.OwnerId, Account__r.Id, Account__r.OwnerId, Student__r.OwnerId
FROM Student_Relationship__c
WHERE Student__r.OwnerId !='0056C000003GwJnQAK'
AND Account__r.OwnerId != '0056C000003GwJnQAK'
LIMIT 20
2. This is OK too
SELECT Contact__r.Id, Contact__r.OwnerId, Account__r.Id, Account__r.OwnerId, Student__r.OwnerId
FROM Student_Relationship__c
WHERE Student__r.OwnerId !='0056C000003GwJnQAK'
AND Contact__r.OwnerId != '0056C000003GwJnQAK'
LIMIT 20
3. But THIS one is Unknown error parsing query
SELECT Contact__r.Id, Contact__r.OwnerId, Account__r.Id, Account__r.OwnerId, Student__r.OwnerId
FROM Student_Relationship__c
WHERE Student__r.OwnerId !='0056C000003GwJnQAK'
AND Contact__r.OwnerId != Account__r.OwnerId
LIMIT 20
I got Unknown error parsing query error. Can somebody explain what is going on, please? Thank you.
1. This is OK
SELECT Contact__r.Id, Contact__r.OwnerId, Account__r.Id, Account__r.OwnerId, Student__r.OwnerId
FROM Student_Relationship__c
WHERE Student__r.OwnerId !='0056C000003GwJnQAK'
AND Account__r.OwnerId != '0056C000003GwJnQAK'
LIMIT 20
2. This is OK too
SELECT Contact__r.Id, Contact__r.OwnerId, Account__r.Id, Account__r.OwnerId, Student__r.OwnerId
FROM Student_Relationship__c
WHERE Student__r.OwnerId !='0056C000003GwJnQAK'
AND Contact__r.OwnerId != '0056C000003GwJnQAK'
LIMIT 20
3. But THIS one is Unknown error parsing query
SELECT Contact__r.Id, Contact__r.OwnerId, Account__r.Id, Account__r.OwnerId, Student__r.OwnerId
FROM Student_Relationship__c
WHERE Student__r.OwnerId !='0056C000003GwJnQAK'
AND Contact__r.OwnerId != Account__r.OwnerId
LIMIT 20
This is expected behaviour from salesforce. We cannot compare two fields in SOQL query. Please find the below article for the same.
https://help.salesforce.com/s/articleView?id=000331053&type=1 (https://help.salesforce.com/s/articleView?id=000331053&type=1)
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
This is expected behaviour from salesforce. We cannot compare two fields in SOQL query. Please find the below article for the same.
https://help.salesforce.com/s/articleView?id=000331053&type=1 (https://help.salesforce.com/s/articleView?id=000331053&type=1)
If this solution helps, Please mark it as best answer.
Thanks,