function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jyoti TrailheadJyoti Trailhead 

Contact record query

I am trying to run this code in Anonymous window:

List<Contact> ConList = New List<Contact>();
ConList = [Select id, name,, from Contact where !=];
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,,,(Select id,name, from Account) from Contact where !=

Please help

 can you explain in your query...
Jyoti TrailheadJyoti Trailhead
Now this error: Line: 2, Column: 11 Invalid bind expression type of Schema.SObjectField for column of type String Regards Jyoti
Steven NsubugaSteven Nsubuga
I was wrong, this scenario is not possible in SOQL..
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.