You need to sign in to do that
Don't have an account?
Jyoti Trailhead
Contact record query
I am trying to run this code in Anonymous window:
List<Contact> ConList = New List<Contact>();
ConList = [Select id, name, Account.name, Parent_Account__r.name from Contact where Parent_Account__r.name != Account.Parent.name];
System.debug('Contact records : ' + Con1);
getting error:
Line: 2, Column: 9
Unexpected token '='.
I need to run below query in Dev console or workbench to get the contact records where Parent Account on Contact is not equal to Parent Account of Account:
select id, name, Account.name, Parent_Account__r.name,(Select id,name, Parent.name from Account) from Contact where Parent_Account__r.name != Account.Parent.name
Please help
List<Contact> ConList = New List<Contact>();
ConList = [Select id, name, Account.name, Parent_Account__r.name from Contact where Parent_Account__r.name != Account.Parent.name];
System.debug('Contact records : ' + Con1);
getting error:
Line: 2, Column: 9
Unexpected token '='.
I need to run below query in Dev console or workbench to get the contact records where Parent Account on Contact is not equal to Parent Account of Account:
select id, name, Account.name, Parent_Account__r.name,(Select id,name, Parent.name from Account) from Contact where Parent_Account__r.name != Account.Parent.name
Please help
can you explain Parent_Account__r.name in your query...
The workaround is to use a checkbox formula field on the Contact object. Then you use this formula field in the where clause of your SOQL query.